Function defer

  • Defers invoking the func until the current call stack has cleared. Any additional arguments are provided to func when it's invoked.

    Type Parameters

    • F extends ((...args: any[]) => any)

    Parameters

    • func: F

      The function to defer.

    • Rest...args: Parameters<F>

      The arguments to invoke func with.

    Returns number

    Returns the timer id.

    defer((text) => {
    console.log(text);
    }, 'deferred');
    // => Logs 'deferred' after the current call stack has cleared.