1 | import { Disposable } from "../index";
|
2 |
|
3 |
|
4 | export class Task {
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | static once(taskPath: string, ...args: any[]): Task;
|
11 |
|
12 |
|
13 | constructor(taskPath: string);
|
14 |
|
15 | // NOTE: this is actually the best we can do here with the REST parameter
|
16 | // for this appearing in the beginning of the parameter list, which isn't
|
17 | // aligned with the ES6 spec.
|
18 | /**
|
19 | * Starts the task.
|
20 | * Throws an error if this task has already been terminated or if sending a
|
21 | * message to the child process fails.
|
22 | */
|
23 | // tslint:disable-next-line:no-any
|
24 | start(...args: any[]): void;
|
25 |
|
26 | /**
|
27 | * Send message to the task.
|
28 | * Throws an error if this task has already been terminated or if sending a
|
29 | * message to the child process fails.
|
30 | */
|
31 | // tslint:disable-next-line:no-any
|
32 | send(message: string | number | boolean | object | null | any[]): void;
|
33 |
|
34 | /** Call a function when an event is emitted by the child process. */
|
35 | // tslint:disable-next-line:no-any
|
36 | on(eventName: string, callback: (param: any) => void): Disposable;
|
37 |
|
38 | /**
|
39 | * Forcefully stop the running task.
|
40 | * No more events are emitted once this method is called.
|
41 | */
|
42 | terminate(): void;
|
43 |
|
44 | /** Cancel the running task and emit an event if it was canceled. */
|
45 | cancel(): boolean;
|
46 | }
|