diff options
Diffstat (limited to 'frontend/src/modules/task/utilities.ts')
-rw-r--r-- | frontend/src/modules/task/utilities.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/frontend/src/modules/task/utilities.ts b/frontend/src/modules/task/utilities.ts new file mode 100644 index 000000000..9f8b8d1e5 --- /dev/null +++ b/frontend/src/modules/task/utilities.ts @@ -0,0 +1,29 @@ +import taskManager from "."; +import { GroupName } from "./group"; + +export function createTask<T extends Task.AnyCallable>( + name: string, + callable: T, + ...parameters: Parameters<T> +): Task.Task { + const callableId = taskManager.create(callable, parameters); + + return { + name, + callableId, + }; +} + +export function dispatchTask(task: Task.Task[], group: GroupName) { + // TODO +} + +export function createAndDispatchTask<T extends Task.AnyCallable>( + name: string, + group: GroupName, + callable: T, + ...parameters: Parameters<T> +) { + const task = createTask(name, callable, ...parameters); + dispatchTask([task], group); +} |