• Combination of bind and async. Binds a method to a given scope and arguments and runs it async.

    Type Parameters

    • Scope
    • MethodName extends string
    • Partials extends any[]

    Parameters

    • scope: Scope

      the scope to bind the function to

    • name: MethodName

      a function to execute async

    • Optional delay: number

      the delay in msec

    • Rest ...partials: Partials

      the arguments pushed to the callback during execution.

    Returns ((...args) => Promise<unknown>)

    the function which runs the cb async

      • (...args): Promise<unknown>
      • Parameters

        • Rest ...args: any[]

        Returns Promise<unknown>

    Deprecated

    use apprt-core/async with plain functions instead

    Example

    import bindAsync from "apprt-core/bindAsync";
    class Counter {
    constructor(){
    this.count = 0;
    }
    inc(){
    return ++this.count;
    }
    }

    let counter = new Counter();
    let asyncInc = bindAsync(counter,"inc");
    // execute counter.inc() async
    asyncInc()
    // result === 1
    .then(result => console.log(result));
  • Type Parameters

    • Scope
    • A extends any[]
    • R
    • Partials extends any[]

    Parameters

    • scope: Scope
    • fn: ((this, ...a) => R)
        • (this, ...a): R
        • Parameters

          Returns R

    • Optional delay: number
    • Rest ...args: Partials

    Returns ((...a) => Promise<R>)

      • (...a): Promise<R>
      • Parameters

        • Rest ...a: any[]

        Returns Promise<R>

    Deprecated

    use apprt-core/async with plain functions instead

Generated using TypeDoc