setCategory
The setCategory
method lets you create and configure a category for tasks.
setCategory(
categoryId: string,
config: TaskRunConfig,
): Manager
Type | Description | |
---|---|---|
categoryId | string | The |
config | TaskRunConfig | The |
returns | Manager | A reference to the |
A category is identified by a string Id
, and all tasks associated with that category will inherit its TaskRunConfig
. If this method is called on a category Id
that already exists, its configuration will be updated.
This has properties which let you indicate the duration of task runs and their retry behaviors, for example.
Examples
This example creates a category called network
with a specific maximum duration.
import {createManager} from 'tinytick';
const manager = createManager();
manager.setCategory('network', {maxDuration: 5000});
console.log(manager.getCategoryConfig('network'));
// -> {maxDuration: 5000}
This example creates a category with some invalid configuration items (which are ignored).
import {createManager} from 'tinytick';
const manager = createManager();
manager.setCategory('network', {
maxDuration: 5000,
maxRetries: -2, // should be a positive integer
oops: 42, // not a valid configuration item
});
console.log(manager.getCategoryConfig('network'));
// -> {maxDuration: 5000}
Since
v1.0.0