Hyperlinkv0.8.0-beta.28

FiberHandle

FiberHandle.getfunctioneffect/FiberHandle.ts:468
<A, E>(self: FiberHandle<A, E>): Effect.Effect<
  Option.Option<Fiber.Fiber<A, E>>
>

Retrieves the fiber from the FiberHandle effectfully.

Example (Reading the current fiber)

import { Effect, Fiber, FiberHandle } from "effect"

Effect.gen(function*() {
  const handle = yield* FiberHandle.make()

  // Add a fiber
  yield* FiberHandle.run(handle, Effect.succeed("hello"))

  // Get the current fiber if present
  const fiber = yield* FiberHandle.get(handle)
  if (fiber._tag === "Some") {
    const result = yield* Fiber.await(fiber.value)
    console.log(result) // "hello"
  }
})
combinators
export function get<A, E>(self: FiberHandle<A, E>): Effect.Effect<Option.Option<Fiber.Fiber<A, E>>> {
  return Effect.suspend(() => Effect.succeed(getUnsafe(self)))
}