Skip to content

✨ add allSettled() operation congruent with Promise.allSettled()#1158

Open
rauhryan wants to merge 2 commits intothefrontside:v4from
rauhryan:rr/all-settled-898-impl
Open

✨ add allSettled() operation congruent with Promise.allSettled()#1158
rauhryan wants to merge 2 commits intothefrontside:v4from
rauhryan:rr/all-settled-898-impl

Conversation

@rauhryan
Copy link
Copy Markdown

Motivation

Addresses #898 — Effection has all() and race() matching Promise.all() and Promise.race(), but lacks an equivalent of Promise.allSettled().

Approach

Adds a new allSettled() operation that runs all given operations concurrently and waits for every one to settle. Unlike all(), it never short-circuits on error — each result is represented as Effection's Result<T> shape ({ ok: true, value } or { ok: false, error }).

Key decisions:

  • Uses Effection's Result<T> rather than PromiseSettledResult<T> so settled outcomes compose consistently with the rest of the library
  • Implements allSettled() by composing existing primitives: all() over box()-wrapped operations
  • Sibling operations are not halted when one fails; all members run to completion and their outcomes are preserved
  • Documents Result, Ok, and Err as public API since allSettled() now exposes Result<T> directly

Files changed

  • lib/all-settled.tsallSettled() implementation and AllSettled mapped type using Result<T>
  • lib/result.ts — public API docs for Result, Ok, and Err
  • test/all-settled.test.ts — coverage for success, failure, teardown, and type inference using Result<T>
  • docs/async-rosetta-stone.mdx and docs/spawn.mdx — updated prose for the Result<T> shape and linked result helpers
  • AGENTS.md — updated guidance for allSettled() semantics

Test coverage

  • Empty list resolves to []
  • All fulfilled → array of { ok: true, value }
  • All rejected → array of { ok: false, error } without throwing
  • Mixed outcomes preserve input order
  • Does not reject when one operation rejects asynchronously
  • Does not halt sibling operations when one fails
  • Runs teardown for all operations after completing
  • Type inference matches the Result<T>-based tuple shape

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant