1.0.2 • Published 5 years ago
@glue42/ng-glue v1.0.2
NgGlue42
Installation
npm install @glue42/desktop @glue42/ng-glueImporting the Glue42 NgModule
Once installed NgGlue42Module needs to be imported and the static method withConfig to be invoked with an optional configuration. withConfig inits an instance of Glue library:
import { NgGlue42Module } from '@glue42/ng-glue';
@NgModule({
imports: [
NgGlue42Module.withConfig({})
]
})
export class AppModule { }Using the library
Start using by injecting any of the provided API into your components and services. For example: In one app listen for a certain method to be registered and immediately invoke it when it becomes available:
import { Component, OnInit } from '@angular/core';
import { InteropService } from '@glue42/ng-glue';
import { mergeMap } from 'rxjs/operators';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html'
})
export class AppComponent implements OnInit {
constructor(public interopService: InteropService) { }
ngOnInit(): void {
this.interopService.methodRegistered({ methodName: 'Sum' })
.pipe(
mergeMap(
() => this.interopService.invoke('Sum', { a: 37, b: 5 })
)
).subscribe(result => {
console.log(`The result of 37 + 5 is ${result.returned.answer}`);
});
}
}In another app register the method:
this.interopService.register('Sum', ({ a, b }) => ({ answer: a + b }))
.subscribe(
method => console.log(`Method "${method.name}" is registered.`),
error => console.log(`Couldn't register method "Sum"`, error)
);1.0.2
5 years ago
1.0.1
6 years ago
1.0.0
6 years ago
0.9.0-alpha.3
6 years ago
0.9.0-alpha.2
6 years ago
0.9.0-alpha.1
6 years ago
0.0.1-alpha.1
6 years ago
0.0.1-alpha.0
6 years ago