From: Jérôme Benoit Date: Sun, 14 Jan 2024 19:58:55 +0000 (+0100) Subject: refactor: refine IWorker interface X-Git-Tag: v3.1.19~11 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a4791fb12ff22711bc4bf1bcae4231ca7d6c7974;p=poolifier.git refactor: refine IWorker interface Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/worker.ts b/src/pools/worker.ts index 30239b11..05f6606e 100644 --- a/src/pools/worker.ts +++ b/src/pools/worker.ts @@ -212,7 +212,7 @@ export interface StrategyData { /** * Worker interface. */ -export interface IWorker { +export interface IWorker extends EventEmitter { /** * Cluster worker id. */ @@ -227,14 +227,14 @@ export interface IWorker { * @param event - The event. * @param handler - The event handler. */ - readonly on: (event: string, handler: EventHandler) => void + readonly on: (event: string, handler: EventHandler) => this /** * Registers once an event handler. * * @param event - The event. * @param handler - The event handler. */ - readonly once: (event: string, handler: EventHandler) => void + readonly once: (event: string, handler: EventHandler) => this /** * Stop all JavaScript execution in the worker thread as soon as possible. * Returns a Promise for the exit code that is fulfilled when the `'exit' event` is emitted.