@epikodelabs/streamix / runInMicrotask
Function: runInMicrotask()
runInMicrotask<
T>(fn):Promise<T>
Defined in: projects/libraries/streamix/src/lib/primitives/scheduling.ts:33
Runs a callback in a microtask and returns its result as a Promise.
Unlike calling Promise.resolve().then(fn) directly, this helper ensures that synchronous throws from fn are converted into a rejected Promise.
Type Parameters
T
T
Return type.
Parameters
fn
() => T | Promise<T>
Callback to run in a microtask.
Returns
Promise<T>
A Promise that resolves to the callback result.