Readonly
activeTasks currently in progress.
Readonly
completedTasks that have completed execution.
Readonly
pendingTasks ready to start but not yet executed.
Checks if there are tasks in the pending
collection.
All tasks managed by the controller.
Adds a single task to the pending
collection.
Task to add.
Adds multiple tasks to the pending
collection.
Tasks to add.
Removes all listeners for all event types, as well as all global listeners.
The EventEmitter instance itself, allowing for method chaining.
Moves tasks from active
to completed
.
ID/s of task/s to complete.
Optional
validityCheck: (task: ExecutableTask) => booleanAn optional callback to determine if the task is valid.
Emits an event of a specific type, invoking all registered listeners for that event type with the provided data. Also calls any global event listeners with a GlobalEvent object.
The identifier for the event type to emit.
The data to pass to the event listeners. The type of this data is defined by the corresponding value in TEvents.
The EventEmitter instance itself, allowing for method chaining.
Removes a previously registered event listener for a specified event type. Use this method to unregister listeners when they are no longer needed, preventing potential memory leaks.
The identifier for the event type from which to remove the listener.
The callback function to unregister.
The EventEmitter instance itself, allowing for method chaining.
Removes a previously registered global event listener.
The global event listener to remove.
The EventEmitter instance itself, allowing for method chaining.
Adds an event listener for a specified event type. This method allows you to specify which event you are interested in listening to and to provide a callback function that will be executed whenever that event is emitted.
The identifier for the event type to listen for.
The callback function that will be called when the event is emitted.
The EventEmitter instance itself, allowing for method chaining.
Adds a global event listener that is called for every emitted event.
The global event listener to add.
The EventEmitter instance itself, allowing for method chaining.
Resets the flow controller, clearing all states.
Array of tasks before the reset.
Moves all tasks from pending
to active
and executes a callback for each task.
Function to execute for each task.
A cleanup function to mark tasks as completed.
The cleanup function accepts an optional validityCheck
callback, which determines
if each task should be marked as valid. The validityCheck
is called for each task
and should return true
for valid tasks and false
otherwise.
Moves the next task from pending
to active
.
The task that was started, or null
if no tasks are pending.
Manages task execution flow by organizing tasks into states (
pending
,active
, andcompleted
).These states are part of the FlowController structure and do not belong to the tasks themselves.