Fiber
Alternatives
Returns a fiber that prefers this fiber, but falls back to the that one
when this one fails. Interrupting the returned fiber will interrupt both
fibers, sequentially, from left to right.
Signature
declare const orElse: { <A2, E2>(that: Fiber<A2, E2>): <A, E>(self: Fiber<A, E>) => Fiber<A2 | A, E2 | E>; <A, E, A2, E2>(self: Fiber<A, E>, that: Fiber<A2, E2>): Fiber<A | A2, E | E2>;}Returns a fiber that prefers this fiber, but falls back to the that one
when this one fails. Interrupting the returned fiber will interrupt both
fibers, sequentially, from left to right.
Signature
declare const orElseEither: { <A2, E2>(that: Fiber<A2, E2>): <A, E>(self: Fiber<A, E>) => Fiber<Either<A2, A>, E2 | E>; <A, E, A2, E2>(self: Fiber<A, E>, that: Fiber<A2, E2>): Fiber<Either<A2, A>, E | E2>;}Constructors
Collects all fibers into a single fiber producing an in-order list of the results.
Signature
declare const all: <A, E>(fibers: Iterable<Fiber<A, E>>) => Fiber<ReadonlyArray<A>, E>A fiber that is done with the specified Exit value.
Signature
declare const done: <A, E>(exit: Exit.Exit<A, E>) => Fiber<A, E>A fiber that has already failed with the specified value.
Signature
declare const fail: <E>(error: E) => Fiber<never, E>Creates a Fiber that has already failed with the specified cause.
Signature
declare const failCause: <E>(cause: Cause.Cause<E>) => Fiber<never, E>Constructrs a Fiber that is already interrupted.
Signature
declare const interrupted: (fiberId: FiberId.FiberId) => Fiber<never>A fiber that never fails or succeeds.
Signature
declare const never: Fiber<never>Returns a chunk containing all root fibers.
Signature
declare const roots: Effect.Effect<Array<RuntimeFiber<any, any>>>Returns a fiber that has already succeeded with the specified value.
Signature
declare const succeed: <A>(value: A) => Fiber<A>Returns a chunk containing all root fibers.
Signature
declare const unsafeRoots: (_: void) => Array<RuntimeFiber<any, any>>Conversions
Lifts an Effect into a Fiber.
Signature
declare const fromEffect: <A, E>(effect: Effect.Effect<A, E>) => Effect.Effect<Fiber<A, E>>Destructors
Awaits on all fibers to be completed, successfully or not.
Signature
declare const awaitAll: <T extends Iterable<Fiber<any, any>>>(fibers: T) => Effect.Effect<[T] extends [ReadonlyArray<infer U>] ? number extends T["length"] ? Array<U extends Fiber<infer A, infer E> ? Exit.Exit<A, E> : never> : { [K in keyof T]: T[K] extends Fiber<infer A, infer E> ? Exit.Exit<A, E> : never } : Array<T extends Iterable<infer U> ? U extends Fiber<infer A, infer E> ? Exit.Exit<A, E> : never : never>>Signature
declare const dump: <A, E>(self: RuntimeFiber<A, E>) => Effect.Effect<Fiber.Dump>Signature
declare const dumpAll: (fibers: Iterable<RuntimeFiber<unknown, unknown>>) => Effect.Effect<Array<Fiber.Dump>>Inherits values from all FiberRef instances into current fiber. This
will resume immediately.
Signature
declare const inheritAll: <A, E>(self: Fiber<A, E>) => Effect.Effect<void>Joins the fiber, which suspends the joining fiber until the result of the fiber has been determined. Attempting to join a fiber that has erred will result in a catchable error. Joining an interrupted fiber will result in an "inner interruption" of this fiber, unlike interruption triggered by another fiber, "inner interruption" can be caught and recovered.
Signature
declare const join: <A, E>(self: Fiber<A, E>) => Effect.Effect<A, E>Joins all fibers, awaiting their successful completion. Attempting to join a fiber that has erred will result in a catchable error, if that error does not result from interruption.
Signature
declare const joinAll: <A, E>(fibers: Iterable<Fiber<A, E>>) => Effect.Effect<Array<A>, E>Pretty-prints a RuntimeFiber.
Signature
declare const pretty: <A, E>(self: RuntimeFiber<A, E>) => Effect.Effect<string>Converts this fiber into a scoped effect. The fiber is interrupted when the scope is closed.
Signature
declare const scoped: <A, E>(self: Fiber<A, E>) => Effect.Effect<Fiber<A, E>, never, Scope.Scope>Folding
Folds over the Fiber or RuntimeFiber.
Signature
declare const match: { <A, E, Z>(options: { readonly onFiber: (fiber: Fiber<A, E>) => Z; readonly onRuntimeFiber: (fiber: RuntimeFiber<A, E>) => Z; }): (self: Fiber<A, E>) => Z; <A, E, Z>(self: Fiber<A, E>, options: { readonly onFiber: (fiber: Fiber<A, E>) => Z; readonly onRuntimeFiber: (fiber: RuntimeFiber<A, E>) => Z; }): Z;}Getters
Retrieves the immediate children of the fiber.
Signature
declare const children: <A, E>(self: Fiber<A, E>) => Effect.Effect<Array<RuntimeFiber<any, any>>>The identity of the fiber.
Signature
declare const id: <A, E>(self: Fiber<A, E>) => FiberId.FiberIdTentatively observes the fiber, but returns immediately if it is not already done.
Signature
declare const poll: <A, E>(self: Fiber<A, E>) => Effect.Effect<Option.Option<Exit.Exit<A, E>>>Returns the FiberStatus of a RuntimeFiber.
Signature
declare const status: <A, E>(self: RuntimeFiber<A, E>) => Effect.Effect<FiberStatus.FiberStatus>Instances
Interruption
Interrupts the fiber from whichever fiber is calling this method. If the fiber has already exited, the returned effect will resume immediately. Otherwise, the effect will resume when the fiber exits.
Signature
declare const interrupt: <A, E>(self: Fiber<A, E>) => Effect.Effect<Exit.Exit<A, E>>Interrupts all fibers, awaiting their interruption.
Signature
declare const interruptAll: (fibers: Iterable<Fiber<any, any>>) => Effect.Effect<void>Interrupts all fibers as by the specified fiber, awaiting their interruption.
Signature
declare const interruptAllAs: { (fiberId: FiberId): (fibers: Iterable<Fiber<any, any>>) => Effect<void>; (fibers: Iterable<Fiber<any, any>>, fiberId: FiberId): Effect<void>;}Interrupts the fiber as if interrupted from the specified fiber. If the fiber has already exited, the returned effect will resume immediately. Otherwise, the effect will resume when the fiber exits.
Signature
declare const interruptAs: { (fiberId: FiberId): <A, E>(self: Fiber<A, E>) => Effect<Exit<A, E>>; <A, E>(self: Fiber<A, E>, fiberId: FiberId): Effect<Exit<A, E>>;}Interrupts the fiber as if interrupted from the specified fiber. If the fiber has already exited, the returned effect will resume immediately. Otherwise, the effect will resume when the fiber exits.
Signature
declare const interruptAsFork: { (fiberId: FiberId): <A, E>(self: Fiber<A, E>) => Effect<void>; <A, E>(self: Fiber<A, E>, fiberId: FiberId): Effect<void>;}Interrupts the fiber from whichever fiber is calling this method. The interruption will happen in a separate daemon fiber, and the returned effect will always resume immediately without waiting.
Signature
declare const interruptFork: <A, E>(self: Fiber<A, E>) => Effect.Effect<void>Mapping
Maps over the value the Fiber computes.
Signature
declare const map: { <A, B>(f: (a: A) => B): <E>(self: Fiber<A, E>) => Fiber<B, E>; <A, E, B>(self: Fiber<A, E>, f: (a: A) => B): Fiber<B, E>;}Effectually maps over the value the fiber computes.
Signature
declare const mapEffect: { <A, A2, E2>(f: (a: A) => Effect<A2, E2>): <E>(self: Fiber<A, E>) => Fiber<A2, E2 | E>; <A, E, A2, E2>(self: Fiber<A, E>, f: (a: A) => Effect<A2, E2>): Fiber<A2, E | E2>;}Passes the success of this fiber to the specified callback, and continues with the fiber that it returns.
Signature
declare const mapFiber: { <E, E2, A, B>(f: (a: A) => Fiber<B, E2>): (self: Fiber<A, E>) => Effect<Fiber<B, E | E2>>; <A, E, E2, B>(self: Fiber<A, E>, f: (a: A) => Fiber<B, E2>): Effect<Fiber<B, E | E2>>;}Models
A fiber is a lightweight thread of execution that never consumes more than a whole thread (but may consume much less, depending on contention and asynchronicity). Fibers are spawned by forking effects, which run concurrently with the parent effect.
Fibers can be joined, yielding their result to other fibers, or interrupted, which terminates the fiber, safely releasing all resources.
Signature
interface Fiber<out A, out E = never> extends Effect<A, E>, Variance<A, E> { readonly [ignoreSymbol]?: FiberUnifyIgnore; readonly [typeSymbol]?: unknown; readonly [unifySymbol]?: FiberUnify<Fiber<A, E>>; readonly await: Effect<Exit<A, E>>; readonly children: Effect<Array<Runtime<any, any>>>; readonly inheritAll: Effect<void>; readonly poll: Effect<Option<Exit<A, E>>>; id(): FiberId; interruptAsFork(fiberId: FiberId): Effect<void>;}FiberUnify
interfaceSignature
interface FiberUnify<A extends { [typeSymbol]?: any;}> extends EffectUnify<A> { Fiber?: () => A[typeof typeSymbol] extends Fiber<A0, E0> | _ ? Fiber<A0, E0> : never;}FiberUnifyIgnore
interfaceSignature
interface FiberUnifyIgnore extends EffectUnifyIgnore { Effect?: true;}RuntimeFiber
interfaceA runtime fiber that is executing an effect. Runtime fibers have an identity and a trace.
Signature
interface RuntimeFiber<out A, out E = never> extends Fiber<A, E>, RuntimeVariance<A, E> { readonly [ignoreSymbol]?: RuntimeFiberUnifyIgnore; readonly [typeSymbol]?: unknown; readonly [unifySymbol]?: RuntimeFiberUnify<RuntimeFiber<A, E>>; readonly runtimeFlags: Effect<RuntimeFlags>; readonly status: Effect<FiberStatus>; currentContext: Context<never>; currentDefaultServices: Context<DefaultServices>; currentOpCount: number; currentScheduler: Scheduler; currentSpan: AnySpan | undefined; currentSupervisor: Supervisor<unknown>; currentTracer: Tracer; addObserver(observer: (exit: Exit<A, E>) => void): void; getFiberRef<X>(fiberRef: FiberRef<X>): X; getFiberRefs(): FiberRefs; id(): Runtime; removeObserver(observer: (exit: Exit<A, E>) => void): void; unsafeInterruptAsFork(fiberId: FiberId): void; unsafePoll(): Exit<A, E> | null;}RuntimeFiberUnify
interfaceSignature
interface RuntimeFiberUnify<A extends { [typeSymbol]?: any;}> extends FiberUnify<A> { RuntimeFiber?: () => A[typeof typeSymbol] extends RuntimeFiber<A0, E0> | _ ? RuntimeFiber<A0, E0> : never;}RuntimeFiberUnifyIgnore
interfaceSignature
interface RuntimeFiberUnifyIgnore extends FiberUnifyIgnore { Fiber?: true;}Other
Refinements
Returns true if the specified value is a Fiber, false otherwise.
Signature
declare const isFiber: (u: unknown) => u is Fiber<unknown, unknown>Returns true if the specified Fiber is a RuntimeFiber, false
otherwise.
Signature
declare const isRuntimeFiber: <A, E>(self: Fiber<A, E>) => self is RuntimeFiber<A, E>Symbols
Signature
declare const FiberTypeId: unique symbolFiberTypeId
typeSignature
type FiberTypeId = typeof FiberTypeIdSignature
declare const RuntimeFiberTypeId: unique symbolRuntimeFiberTypeId
typeSignature
type RuntimeFiberTypeId = typeof RuntimeFiberTypeIdUtilities
Gets the current fiber if one is running.
Signature
declare const getCurrentFiber: () => Option.Option<RuntimeFiber<any, any>>Zipping
Zips this fiber and the specified fiber together, producing a tuple of their output.
Signature
declare const zip: { <A2, E2>(that: Fiber<A2, E2>): <A, E>(self: Fiber<A, E>) => Fiber<[A, A2], E2 | E>; <A, E, A2, E2>(self: Fiber<A, E>, that: Fiber<A2, E2>): Fiber<[A, A2], E | E2>;}Same as zip but discards the output of that Fiber.
Signature
declare const zipLeft: { <A2, E2>(that: Fiber<A2, E2>): <A, E>(self: Fiber<A, E>) => Fiber<A, E2 | E>; <A, E, A2, E2>(self: Fiber<A, E>, that: Fiber<A2, E2>): Fiber<A, E | E2>;}Same as zip but discards the output of this Fiber.
Signature
declare const zipRight: { <A2, E2>(that: Fiber<A2, E2>): <A, E>(self: Fiber<A, E>) => Fiber<A2, E2 | E>; <A, E, A2, E2>(self: Fiber<A, E>, that: Fiber<A2, E2>): Fiber<A2, E | E2>;}Zips this fiber with the specified fiber, combining their results using the specified combiner function. Both joins and interruptions are performed in sequential order from left to right.
Signature
declare const zipWith: { <B, E2, A, C>(that: Fiber<B, E2>, f: (a: A, b: B) => C): <E>(self: Fiber<A, E>) => Fiber<C, E2 | E>; <A, E, B, E2, C>(self: Fiber<A, E>, that: Fiber<B, E2>, f: (a: A, b: B) => C): Fiber<C, E | E2>;}