TinyTick logoTinyTick

getCategoryConfig

The getCategoryConfig method returns the current configuration of a category.

getCategoryConfig<WithDefaults>(
  categoryId: string,
  withDefaults?: WithDefaults,
): WithDefaults extends true ? TaskRunConfigWithDefaults : undefined | TaskRunConfig
TypeDescription
categoryIdstring

The Id of the category to get the configuration for.

withDefaults?WithDefaults

An optional boolean indicating whether to return the full configuration, including defaults.

returnsWithDefaults extends true ? TaskRunConfigWithDefaults : undefined | TaskRunConfig

The configuration as a TaskRunConfig (or undefined if the category Id does not exist) or TaskRunConfigWithDefaults.

You can either return just the configuration you have set for this category, or the full configuration, including any defaults of those you have not provided.

If the category Id does not exist, this method will return undefined.

Examples

This example creates a category called network with a specific maximum duration. Its configuration can be accessed with or without the defaults included.

import {createManager} from 'tinytick';

const manager = createManager();
manager.setCategory('network', {maxDuration: 5000});

console.log(manager.getCategoryConfig('network'));
// -> {maxDuration: 5000}
console.log(manager.getCategoryConfig('network', true));
// -> {maxDuration: 5000, maxRetries: 0, retryDelay: 1000, repeatDelay: null}

This example tries to get the configuration of a category that does not exist. The method returns undefined.

import {createManager} from 'tinytick';

const manager = createManager();

console.log(manager.getCategoryConfig('oops'));
// -> undefined
console.log(manager.getCategoryConfig('oops', true));
// -> undefined

Since

v1.0.0