Hyperlinkv0.8.0-beta.28

Fiber

Fiber.joinconsteffect/Fiber.ts:272
<A, E>(self: Fiber<A, E>): Effect<A, E>

Joins a fiber, blocking until it completes. If the fiber succeeds, returns its value. If it fails, the error is propagated.

When to use

Use when you need a forked fiber's failure to fail the current Effect because that fiber is part of the current workflow.

Gotchas

Joining a failed fiber propagates the fiber's Cause. Use await when you need to inspect the Exit instead of failing.

Example (Joining a fiber)

import { Effect, Fiber } from "effect"

const program = Effect.gen(function*() {
  const fiber = yield* Effect.forkChild(Effect.succeed(42))
  const result = yield* Fiber.join(fiber)
  console.log(result) // 42
})
combinatorsawait_
Source effect/Fiber.ts:2721 lines
export const join: <A, E>(self: Fiber<A, E>) => Effect<A, E> = effect.fiberJoin
Referenced by 1 symbols