@acknow-srl/sharedeprecated

Reads and manages shared data.

Usage no npm install needed!

<script type="module">
  import acknowSrlShare from 'https://cdn.skypack.dev/@acknow-srl/share';
</script>

README

Share

Reads and manages shared data.

AckShare (Service)

Methods

  • get(): Observable<any>: returns an Observable with the current shared data.
  • set(data: any): void: sets new shared data.

Example

/**
 * 1. Import the module in your main module (usually app.module.ts).
 */

import { AckShareModule, AckShare } from '@acknow-srl/share';

/**
 * 2. Add the module to your app imports.
 */

@NgModule({
  declarations: [
    AppComponent
    ...
  ],
  imports: [
    ...
    AckShareModule,
    ...
  ],
  bootstrap: [AppComponent]
})
export class AppModule {

    /**
     * 3. Set some shared data.
     */

    constructor(private share: AckShare) {

        let data = [
            {
                name: 'Adam',
                surname: 'Smith'
            },
            {
                name: 'John Maynard',
                surname: 'Keynes'
            }
        ];

        this.share.set(data);
    }

}

/**
 * 4. In your components or services, read the shared data.
 */

import { Component } from '@angular/core';

import { AckShare } from '@acknow-srl/share';

@Component({
    ...
})
export class MyComponent {

    data: any;

    constructor(private share: AckShare) {
    }

    getSharedData() {
       return this.share.get().subscribe(data => {
           this.data = data;
       });
    }

}