# @glue42/ng-glue

> Glue42 library for Angular

Latest version **1.0.2** (published 2020-11-04) · SEE LICENSE IN license.md license · 0 weekly downloads

## Install

```sh
npm install @glue42/ng-glue
pnpm add @glue42/ng-glue
yarn add @glue42/ng-glue
bun add @glue42/ng-glue
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-11-04 |
| First published | 2019-08-29 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN license.md |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 1.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Glue42 |
| Maintainers | flashd2n, suzunov, k.parushev, kiril.popov |
| Keywords | glue, glue42, desktop, interop, context, angular, rxjs |

## Links

- npm: https://www.npmjs.com/package/@glue42/ng-glue
- Homepage: https://glue42.com/
- npm.io page: https://npm.io/package/@glue42/ng-glue

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^1.9.0

## Recent versions

- 1.0.2 (latest) — 2020-11-04
- 1.0.1 — 2020-04-02
- 1.0.0 — 2019-10-28
- 0.9.0-alpha.3 — 2019-10-16
- 0.9.0-alpha.2 — 2019-10-07
- 0.9.0-alpha.1 — 2019-09-30
- 0.0.1-alpha.1 — 2019-08-29
- 0.0.1-alpha.0 — 2019-08-29

## README

# NgGlue42

## Installation

```
npm install @glue42/desktop @glue42/ng-glue
```

## Importing 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:

```typescript
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:

```typescript
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:
```typescript
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)
  );
```

---
_Source: https://npm.io/package/@glue42/ng-glue · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
