effect-io-ai

Package: effect
Module: Fiber

Fiber.getCurrent

Returns the current fiber if called from within a fiber context, otherwise returns undefined.

When to use

Use when you need low-level runtime integrations that need access to the currently executing fiber.

Gotchas

This is a synchronous accessor, not an Effect. It returns undefined outside an active fiber runtime context.

Example (Getting the current fiber)

import { Effect, Fiber } from "effect"

const program = Effect.gen(function*() {
  const current = Fiber.getCurrent()
  if (current) {
    console.log(`Current fiber ID: ${current.id}`)
  }
})

Signature

declare const getCurrent: () => Fiber<any, any> | undefined

Source

Since v4.0.0