Creates a subscriber which forwards received values to given worker.
remarks
The worker can be an existing Worker instance, a JS source code Blob or an URL string. In the latter two cases, a worker is created automatically. If transfer is true, the received values will be marked as transferrable and the host app loses all access permissions to these marked values. See Worker.postMessage() for details.
If terminate is set to a positive number, then the worker will be automatically terminated after the stated number of milliseconds since the parent subscription is ISubscriber.done.
Creates a subscriber which forwards received values to given worker.
The
worker
can be an existingWorker
instance, a JS source codeBlob
or an URL string. In the latter two cases, a worker is created automatically. Iftransfer
is true, the received values will be marked as transferrable and the host app loses all access permissions to these marked values. SeeWorker.postMessage()
for details.If
terminate
is set to a positive number, then the worker will be automatically terminated after the stated number of milliseconds since the parent subscription is ISubscriber.done.// worker source code src = `self.onmessage = (e) => console.log("worker", e.data);`; a = stream(); a.subscribe( postWorker(src, { type: "application/javascript" })) ); a.next(42) // worker 42