Deferred
Constructors
Creates a new Deferred.
Signature
declare const make: <A, E = never>() => Effect.Effect<Deferred<A, E>>Creates a new Deferred from the specified FiberId.
Signature
declare const makeAs: <A, E = never>(fiberId: FiberId.FiberId) => Effect.Effect<Deferred<A, E>>Getters
Returns true if this Deferred has already been completed with a value or
an error, false otherwise.
Signature
declare const isDone: <A, E>(self: Deferred<A, E>) => Effect.Effect<boolean>Returns a Some<Effect<A, E, R>> from the Deferred if this Deferred has
already been completed, None otherwise.
Signature
declare const poll: <A, E>(self: Deferred<A, E>) => Effect.Effect<Option.Option<Effect.Effect<A, E>>>Models
A Deferred represents an asynchronous variable that can be set exactly
once, with the ability for an arbitrary number of fibers to suspend (by
calling Deferred.await) and automatically resume when the variable is set.
Deferred can be used for building primitive actions whose completions
require the coordinated action of multiple fibers, and for building
higher-level concurrent or asynchronous structures.
Signature
interface Deferred<in out A, in out E = never> extends Effect<A, E>, Variance<A, E> { readonly [ignoreSymbol]?: DeferredUnifyIgnore; readonly [typeSymbol]?: unknown; readonly [unifySymbol]?: DeferredUnify<Deferred<A, E>>;}DeferredUnify interface
Signature
interface DeferredUnify<A extends { [typeSymbol]?: any;}> extends EffectUnify<A> { Deferred?: () => Extract<A[typeof typeSymbol], Deferred<any, any>>;}DeferredUnifyIgnore interface
Signature
interface DeferredUnifyIgnore extends EffectUnifyIgnore { Effect?: true;}Other
Symbols
DeferredTypeId
Signature
declare const DeferredTypeId: unique symbolDeferredTypeId type
Signature
type DeferredTypeId = typeof DeferredTypeIdUnsafe
unsafeDone
Unsafely exits the Deferred with the specified Exit value, which will be
propagated to all fibers waiting on the value of the Deferred.
Signature
declare const unsafeDone: <A, E>(self: Deferred<A, E>, effect: Effect.Effect<A, E>) => voidunsafeMake
Unsafely creates a new Deferred from the specified FiberId.
Signature
declare const unsafeMake: <A, E = never>(fiberId: FiberId.FiberId) => Deferred<A, E>Utils
Completes the deferred with the result of the specified effect. If the deferred has already been completed, the method will produce false.
Note that Deferred.completeWith will be much faster, so consider using
that if you do not need to memoize the result of the specified effect.
Signature
declare const complete: { <A, E>(effect: Effect<A, E>): (self: Deferred<A, E>) => Effect<boolean>; <A, E>(self: Deferred<A, E>, effect: Effect<A, E>): Effect<boolean>;}completeWith
Completes the deferred with the result of the specified effect. If the deferred has already been completed, the method will produce false.
Signature
declare const completeWith: { <A, E>(effect: Effect<A, E>): (self: Deferred<A, E>) => Effect<boolean>; <A, E>(self: Deferred<A, E>, effect: Effect<A, E>): Effect<boolean>;}Kills the Deferred with the specified defect, which will be propagated to
all fibers waiting on the value of the Deferred.
Signature
declare const die: { (defect: unknown): <A, E>(self: Deferred<A, E>) => Effect<boolean>; <A, E>(self: Deferred<A, E>, defect: unknown): Effect<boolean>;}Kills the Deferred with the specified defect, which will be propagated to
all fibers waiting on the value of the Deferred.
Signature
declare const dieSync: { (evaluate: LazyArg<unknown>): <A, E>(self: Deferred<A, E>) => Effect<boolean>; <A, E>(self: Deferred<A, E>, evaluate: LazyArg<unknown>): Effect<boolean>;}Exits the Deferred with the specified Exit value, which will be
propagated to all fibers waiting on the value of the Deferred.
Signature
declare const done: { <A, E>(exit: Exit<A, E>): (self: Deferred<A, E>) => Effect<boolean>; <A, E>(self: Deferred<A, E>, exit: Exit<A, E>): Effect<boolean>;}Fails the Deferred with the specified error, which will be propagated to
all fibers waiting on the value of the Deferred.
Signature
declare const fail: { <E>(error: E): <A>(self: Deferred<A, E>) => Effect<boolean>; <A, E>(self: Deferred<A, E>, error: E): Effect<boolean>;}Fails the Deferred with the specified Cause, which will be propagated to
all fibers waiting on the value of the Deferred.
Signature
declare const failCause: { <E>(cause: Cause<E>): <A>(self: Deferred<A, E>) => Effect<boolean>; <A, E>(self: Deferred<A, E>, cause: Cause<E>): Effect<boolean>;}failCauseSync
Fails the Deferred with the specified Cause, which will be propagated to
all fibers waiting on the value of the Deferred.
Signature
declare const failCauseSync: { <E>(evaluate: LazyArg<Cause<E>>): <A>(self: Deferred<A, E>) => Effect<boolean>; <A, E>(self: Deferred<A, E>, evaluate: LazyArg<Cause<E>>): Effect<boolean>;}Fails the Deferred with the specified error, which will be propagated to
all fibers waiting on the value of the Deferred.
Signature
declare const failSync: { <E>(evaluate: LazyArg<E>): <A>(self: Deferred<A, E>) => Effect<boolean>; <A, E>(self: Deferred<A, E>, evaluate: LazyArg<E>): Effect<boolean>;}Completes the Deferred with interruption. This will interrupt all fibers
waiting on the value of the Deferred with the FiberId of the fiber
calling this method.
Signature
declare const interrupt: <A, E>(self: Deferred<A, E>) => Effect.Effect<boolean>interruptWith
Completes the Deferred with interruption. This will interrupt all fibers
waiting on the value of the Deferred with the specified FiberId.
Signature
declare const interruptWith: { (fiberId: FiberId): <A, E>(self: Deferred<A, E>) => Effect<boolean>; <A, E>(self: Deferred<A, E>, fiberId: FiberId): Effect<boolean>;}Completes the Deferred with the specified value.
Signature
declare const succeed: { <A>(value: A): <E>(self: Deferred<A, E>) => Effect<boolean>; <A, E>(self: Deferred<A, E>, value: A): Effect<boolean>;}Completes the Deferred with the specified lazily evaluated value.
Signature
declare const sync: { <A>(evaluate: LazyArg<A>): <E>(self: Deferred<A, E>) => Effect<boolean>; <A, E>(self: Deferred<A, E>, evaluate: LazyArg<A>): Effect<boolean>;}