getTaskConfig
The getTaskConfig
method returns the current configuration of a Task
.
getTaskConfig<WithDefaults>(
taskId: string,
withDefaults?: WithDefaults,
): WithDefaults extends true ? TaskRunConfigWithDefaults : undefined | TaskRunConfig
Type | Description | |
---|---|---|
taskId | string | The |
withDefaults? | WithDefaults | An optional boolean indicating whether to return the full configuration, including defaults. |
returns | WithDefaults extends true ? TaskRunConfigWithDefaults : undefined | TaskRunConfig | The configuration as a |
You can either return just the configuration you have set for this Task
, or the full configuration, including any inherited from the category, or defaults of those you have not provided.
If the task Id
does not exist, this method will return undefined
.
Examples
This example creates a category, and registers a task for which the configuration is returned.
import {createManager} from 'tinytick';
const manager = createManager();
manager.setCategory('network', {maxDuration: 5000});
manager.setTask(
'ping',
async () => await fetch('https://example.org'),
'network',
{maxRetries: 3},
);
console.log(manager.getTaskConfig('ping', true));
// -> {maxDuration: 5000, maxRetries: 3, retryDelay: 1000, repeatDelay: null}
This example tries to return the configuration of a task that does not exist. The method returns undefined
.
import {createManager} from 'tinytick';
const manager = createManager();
console.log(manager.getTaskConfig('oops'));
// -> undefined
console.log(manager.getTaskConfig('oops', true));
// -> undefined
Since
v1.0.0