getTaskRunInfo
The getTaskRunInfo
method returns information about a scheduled or running task run.
getTaskRunInfo(taskRunId: string): undefined | TaskRunInfo
Type | Description | |
---|---|---|
taskRunId | string | The |
returns | undefined | TaskRunInfo | The |
If the task run Id
does not exist, this method will return undefined
.
Examples
This example registers a task that is then scheduled to run. The info is then returned.
import {createManager} from 'tinytick';
const manager = createManager();
manager.setTask('ping', async (url) => await fetch(url));
const taskRunId = manager.scheduleTaskRun('ping', 'https://example.org');
const info = manager.getTaskRunInfo(taskRunId);
console.log(info.taskId);
// -> 'ping'
console.log(info.arg);
// -> 'https://example.org'
console.log(info.running);
// -> false
This example tries to return the info of a task run that does not exist. The method returns undefined
.
import {createManager} from 'tinytick';
const manager = createManager();
console.log(manager.getTaskRunInfo('oops'));
// -> undefined
console.log(manager.getTaskRunInfo('oops', true));
// -> undefined
Since
v1.0.0