function allSettled
thefrontside/effectionfunction* allSettled<T extends readonly Operation<unknown>[] | []>(ops: T): Operation<AllSettled<T>>
Block and wait for all of the given operations to settle. Returns an array of results indicating whether each operation succeeded or errored. This has the same purpose as Promise.allSettled.
Unlike all, allSettled never rejects — every operation
result is represented as either { ok: true, value } or
{ ok: false, error }.
Example
import { allSettled, main, until } from 'effection';
await main(function*() {
let [google, notASite] = yield* allSettled([
until(fetch('http://google.com')),
until(fetch('http://nope.example')),
]);
// google => { ok: true, value: Response }
// notASite => { ok: false, error: Error }
});
Type Parameters
T extends readonly Operation<unknown>[] | []
Parameters
ops: T
a list of operations to wait for
Return Type
Operation<AllSettled<T>>
the list of settled results, in the order they were given