Options
All
  • Public
  • Public/Protected
  • All
Menu

Package muster-worker

Muster Worker

Introduction

Nodes for running a Muster Graph in a standalone Worker thread.

Usage

Create a worker script, standalone from your app, and configure your worker's graph in it. Run workerConnect to enable worker messaging.

import muster from '@dws/muster';
import { workerConnect } from '@dws/muster-worker';

const graph = muster({ // ... });

workerConnect(graph, self);

In your app, use the worker to create a connection to the worker's graph. You'll need to pass in the path to your deployed worker script.

import muster, { ref } from '@dws/muster';
import { worker } from '@dws/muster-worker';

const clientApp = muster({ worker: worker('./my.worker.js'), // ... });

For hints on how to configure webpack to build and deploy your worker script, see the repo's webpack config.

Install

With npm installed, run

$ npm install @dws/muster-worker

License

MIT

Index

Variables

Let age

age: number = 1

Const clientApp

clientApp: Muster = muster({worker: worker('./app.worker.js', { log: true }),})

Const ctx

ctx: any = self as DedicatedWorkerGlobalScope

Const document

document: any

Const graph

graph: Muster = muster({nameStream: fromStream(subject),})

Const subject

subject: BehaviorSubject<ValueNodeDefinition<string>> = new BehaviorSubject(value(`Geoff is ${age}`))

Functions

getWorker

  • getWorker(workerPath: string): Worker

worker

workerConnect

workerMiddleware