UNPKG

@xylabs/threads

Version:

Web workers & worker threads as simple as a function call

17 lines (14 loc) 861 B
import { Observable } from 'observable-fns'; import { T as Thread$1, W as WorkerEvent } from '../master-zgnSDvrP.js'; import '../observable-promise.js'; type Thread = Thread$1; /** Thread utility functions. Use them to manage or inspect a `spawn()`-ed thread. */ declare const Thread: { /** Return an observable that can be used to subscribe to all errors happening in the thread. */ errors<ThreadT extends Thread$1>(thread: ThreadT): Observable<Error>; /** Return an observable that can be used to subscribe to internal events happening in the thread. Useful for debugging. */ events<ThreadT extends Thread$1>(thread: ThreadT): Observable<WorkerEvent>; /** Terminate a thread. Remember to terminate every thread when you are done using it. */ terminate<ThreadT extends Thread$1>(thread: ThreadT): Promise<void>; }; export { Thread };