Skip to content

Commit

Permalink
change return type of Fiber.joinAll to return an array (#2521)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim <hello@timsmart.co>
  • Loading branch information
patroza and tim-smart committed Apr 16, 2024
1 parent e2aaaba commit 6424181
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-onions-kneel.md
@@ -0,0 +1,5 @@
---
"effect": patch
---

change return type of Fiber.joinAll to return an array
2 changes: 1 addition & 1 deletion packages/effect/src/Fiber.ts
Expand Up @@ -451,7 +451,7 @@ export const join: <A, E>(self: Fiber<A, E>) => Effect.Effect<A, E> = internal.j
* @since 2.0.0
* @category destructors
*/
export const joinAll: <A, E>(fibers: Iterable<Fiber<A, E>>) => Effect.Effect<void, E> = fiberRuntime.fiberJoinAll
export const joinAll: <A, E>(fibers: Iterable<Fiber<A, E>>) => Effect.Effect<Array<A>, E> = fiberRuntime.fiberJoinAll

/**
* Maps over the value the Fiber computes.
Expand Down
4 changes: 2 additions & 2 deletions packages/effect/src/internal/fiberRuntime.ts
Expand Up @@ -3263,8 +3263,8 @@ export const fiberInterruptFork = <A, E>(self: Fiber.Fiber<A, E>): Effect.Effect
core.asUnit(forkDaemon(core.interruptFiber(self)))

/* @internal */
export const fiberJoinAll = <A, E>(fibers: Iterable<Fiber.Fiber<A, E>>): Effect.Effect<void, E> =>
core.asUnit(internalFiber.join(fiberAll(fibers)))
export const fiberJoinAll = <A, E>(fibers: Iterable<Fiber.Fiber<A, E>>): Effect.Effect<Array<A>, E> =>
internalFiber.join(fiberAll(fibers))

/* @internal */
export const fiberScoped = <A, E>(self: Fiber.Fiber<A, E>): Effect.Effect<Fiber.Fiber<A, E>, never, Scope.Scope> =>
Expand Down
4 changes: 3 additions & 1 deletion packages/effect/test/Fiber.test.ts
Expand Up @@ -215,7 +215,9 @@ describe("Fiber", () => {
it.effect("joinAll - stack safety", () =>
Effect.gen(function*($) {
const result = yield* $(Fiber.joinAll(fibers))
assert.isUndefined(result)
assert.isArray(result)
assert(result.length === fibers.length)
result.forEach((_) => assert.isUndefined(_))
}), 10000)
it.effect("all - stack safety", () =>
Effect.gen(function*($) {
Expand Down

0 comments on commit 6424181

Please sign in to comment.