Combination of bind and async. Binds a method to a given scope and arguments and runs it async.
the scope to bind the function to
a function to execute async
Optional
the delay in msec
the arguments pushed to the callback during execution.
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() asyncconst result = await asyncInc();// result === 1console.log(result)); Copy
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() asyncconst result = await asyncInc();// result === 1console.log(result));
Combination of bind and async. Binds a method to a given scope and arguments and runs it async.