effect-io-ai

Package: effect
Module: FiberHandle

FiberHandle.get

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"
  }
})

Signature

declare const get: <A, E>(self: FiberHandle<A, E>) => Effect.Effect<Option.Option<Fiber.Fiber<A, E>>>

Source

Since v2.0.0