signalk-worker-angular
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.3 • Public • Published

    signalk-worker-angular: WebWorker library for signalk-client-angular

    Note: This library was generated with Angular CLI version 12.0.0.


    This library provides a wrapper for the stream class within signalk-client-angular library to facilitate communication with a Signal K server STREAM API via a WebWorker within an Angular application.

    SignalKStreamWorker class exposes all attributes and methodsof the stream class for interacting with Signal K STREAM API

    Please refer to the signalk-client-angular documentation on GitHub.


    Installation

    signalk-worker-angular has a dependency on signalk-client-angular version 1.8.0 or greater so ensure both libraries are installed.

    npm install signalk-client-angular signalk-worker-angular
    

    Usage

    To create the worker in your project:

    ng g webWorker skstream
    

    this will create the file skstream.worker.ts in your project.

    skstream.worker.ts

    • Include SignalKStreamWorker in your worker and instantate an instance.
    import { SignalKStreamWorker } from 'signalk-worker-angular';
    
    let skstream= new SignalKStreamWorker();
    
    • You can use the instantitated SignalKStreamWorker instance to access all stream class methods and attributes.

    app.component.ts

    • Create a WebWorker and handle messages from it.
    this.worker = new Worker('./skstream.worker', { 
        type: 'module' 
    });
    
    this.worker.onmessage = ({ data }) => {
        console.log('From Web Worker:', data );
    };
    
    • Send messages to the worker using postMessage()
    this.worker.postMessage({  ... });
    

    Install

    npm i signalk-worker-angular

    DownloadsWeekly Downloads

    2

    Version

    1.1.3

    License

    Apache-20

    Unpacked Size

    66.2 kB

    Total Files

    12

    Last publish

    Collaborators

    • panaaj