TinyTick logoTinyTick

getTaskRunConfig

The getTaskRunConfig method returns the configuration of a task run.

getTaskRunConfig<WithDefaults>(
  taskRunId: string,
  withDefaults?: WithDefaults,
): WithDefaults extends true ? TaskRunConfigWithDefaults : undefined | TaskRunConfig
TypeDescription
taskRunIdstring

The Id of the task run 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 task run Id does not exist) or TaskRunConfigWithDefaults.

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

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

Examples

This example registers a task that has a category and that is then scheduled to run. The configuration is then 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},
);
const taskRunId = manager.scheduleTaskRun('ping', '', 0, {retryDelay: 10});

console.log(manager.getTaskRunConfig(taskRunId));
// -> {retryDelay: 10}
console.log(manager.getTaskRunConfig(taskRunId, true));
// -> {maxDuration: 5000, maxRetries: 3, retryDelay: 10, repeatDelay: null}

This example tries to return the configuration of a task run that does not exist. The method returns undefined.

import {createManager} from 'tinytick';

const manager = createManager();

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

Since

v1.0.0