@thi.ng/rstream
Version:
Reactive streams & subscription primitives for constructing dataflow graphs / pipelines
30 lines • 1.15 kB
TypeScript
import type { WithErrorHandlerOpts, WorkerSource } from "./api.js";
export interface FromWorkerOpts extends WithErrorHandlerOpts {
/**
* If true, the worker will be terminated when the stream
* is being closed.
*
* @defaultValue true
*/
terminate: boolean;
}
/**
* Returns a {@link Stream} which adds `message` and `error` event
* listeners to given `worker` and then emits received values.
*
* @remarks
* If `terminate` is true (default), the worker will be terminated when
* the stream is being closed (either directly or indirectly, i.e. if
* the user called {@link ISubscriber.done} on the stream or the last
* child subscription has unsubscribed, depending on
* {@link CommonOpts | config options}).
*
* As with {@link postWorker}, 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.
*
* @param worker -
* @param opts -
*/
export declare const fromWorker: <T>(worker: WorkerSource, opts?: Partial<FromWorkerOpts>) => import("./stream.js").Stream<T>;
//# sourceMappingURL=worker.d.ts.map