getRunningTaskRunIds
The getRunningTaskRunIds
method returns an array containing all running task run Ids
.
getRunningTaskRunIds(): Ids
When first scheduled, a task run will not appear in this list, but will appear in the list of scheduled task runs, accessible with the getScheduledTaskRunIds
method. Once it starts running, it will instead move to appear on this list.
Example
This example registers a task that is then scheduled to run. Once it runs, its Id
appears on the list of running tasks.
import {createManager} from 'tinytick';
const manager = createManager();
manager.setTask('ping', async () => await fetch('https://example.org'));
const taskRunId = manager.scheduleTaskRun('ping');
console.log(manager.getScheduledTaskRunIds().length);
// -> 1
console.log(manager.getRunningTaskRunIds().length);
// -> 0
manager.start();
// ... wait 100ms (the Manager tickInterval) for task run to start
console.log(manager.getScheduledTaskRunIds().length);
// -> 0
console.log(manager.getRunningTaskRunIds().length);
// -> 1
console.log(manager.getRunningTaskRunIds()[0] == taskRunId);
// -> true
// ... wait 100ms (another tick) for task run to finish
console.log(manager.getScheduledTaskRunIds().length);
// -> 0
console.log(manager.getRunningTaskRunIds().length);
// -> 0
Since
v1.0.0