PulseTask class represents a task with a callback function and various options.

Type Parameters

  • Params extends any[]

    The types of the parameters that the task's callback function accepts.

Constructors

Properties

[_ID]: string
[_attempt]: number
[_attempts]: number
[_autostart]: boolean
[_callback]: PulseCallback<Params>
[_complete]: boolean
[_count]: number
[_delay]: number
[_error]: null | Error
[_params]: Params
[_repeat]: number
[_status]: STATUS
[_timer]: any
isDebugging: boolean = false
ENUMS: {
    DEBUG: boolean;
    DEFAULT: {
        ATTEMPTS: number;
        AUTOSTART: boolean;
        DELAY: number;
        REPEAT: number;
    };
    ERROR: {
        CALLBACK: string;
        ID: string;
    };
    STATUS: typeof STATUS;
} = ENUMS

Type declaration

  • DEBUG: boolean
  • DEFAULT: {
        ATTEMPTS: number;
        AUTOSTART: boolean;
        DELAY: number;
        REPEAT: number;
    }
    • ATTEMPTS: number
    • AUTOSTART: boolean
    • DELAY: number
    • REPEAT: number
  • ERROR: {
        CALLBACK: string;
        ID: string;
    }
    • CALLBACK: string
    • ID: string
  • STATUS: typeof STATUS

Accessors

  • get progress(): number
  • Gets the progress of the task. If the task is set to repeat indefinitely, it returns 0. Otherwise, it calculates the progress as the ratio of the count to the repeat value.

    Returns number

    The fractional progress of the task.

Methods

  • Logs the provided arguments to the console if debugging is enabled. Debugging is enabled by setting the debug option to true in the options object passed to the constructor.

    Parameters

    • Rest ...args: any[]

      The arguments to be logged.

    Returns void

  • Immediately executes the task and updates the task status to RUNNING. If the task execution results in an error or returns false, it throws a PulseTaskError. Otherwise, it calls the onSuccess method with the result of the task execution.

    Returns Promise<undefined | PulseTask<Params>>

    Returns the instance of the task.

    Throws

    Throws a PulseTaskError if the task execution results in an error or returns false.