-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.ts
More file actions
30 lines (27 loc) · 1017 Bytes
/
command.ts
File metadata and controls
30 lines (27 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import {TaskContext} from "./context.js";
import {Task} from "./task.js";
import {TaskResult} from "./taskResult.js";
import {TaskSpec} from "./taskSpec.js";
/**
* A command is a set of tasks that are created and queued for execution.
*
* This is the contract you need to implement when you want to use cuttlecat to search for something on GitHub.
*/
export interface Command<R extends TaskResult, S extends TaskSpec, T extends Task<R, S>> {
/**
* When the queue is empty (ie. creating a new queue, instead of resuming an existing one), this method is called to
* create the initial set of tasks.
*
* @param context
*/
createNewQueueItems(context:TaskContext):S[];
/**
* Create a task implementation for the given spec.
* The spec could be a new one just created by createNewQueueItems, or it could be one that was persisted and is now
* being resumed.
*
* @param context
* @param spec
*/
createTask(context:TaskContext, spec:S):T;
}