• 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

    • Optionaldelay: number

      the delay in msec

    • ...partials: Partials

      the arguments pushed to the callback during execution.

    Returns (...args: any[]) => Promise<unknown>

    the function which runs the cb async

    use apprt-core/async with plain functions instead

    import bindAsync from "apprt-core/bindAsync";
    class Counter {
    count = 0;
    inc() {
    return ++this.count;
    }
    }
    const counter = new Counter();
    const asyncInc = bindAsync(counter, "inc");
    // execute counter.inc() async
    const result = await asyncInc();
    // result === 1
    console.log(result));
  • Type Parameters

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

    Parameters

    Returns (...a: any[]) => Promise<R>

    use apprt-core/async with plain functions instead