ScopedRef overview
Added in v2.0.0
Table of contents
constructors
fromAcquire
Creates a new ScopedRef
from an effect that resourcefully produces a value.
Signature
export declare const fromAcquire: <A, E, R>(
acquire: Effect.Effect<A, E, R>
) => Effect.Effect<ScopedRef<A>, E, Scope.Scope | R>
Added in v2.0.0
make
Creates a new ScopedRef
from the specified value. This method should not be used for values whose creation require the acquisition of resources.
Signature
export declare const make: <A>(evaluate: LazyArg<A>) => Effect.Effect<ScopedRef<A>, never, Scope.Scope>
Added in v2.0.0
getters
get
Retrieves the current value of the scoped reference.
Signature
export declare const get: <A>(self: ScopedRef<A>) => Effect.Effect<A>
Added in v2.0.0
set
Sets the value of this reference to the specified resourcefully-created value. Any resources associated with the old value will be released.
This method will not return until either the reference is successfully changed to the new value, with old resources released, or until the attempt to acquire a new value fails.
Signature
export declare const set: {
<A, R, E>(acquire: Effect.Effect<A, E, R>): (self: ScopedRef<A>) => Effect.Effect<void, E, Exclude<R, Scope.Scope>>
<A, R, E>(self: ScopedRef<A>, acquire: Effect.Effect<A, E, R>): Effect.Effect<void, E, Exclude<R, Scope.Scope>>
}
Added in v2.0.0
models
ScopedRef (interface)
A ScopedRef
is a reference whose value is associated with resources, which must be released properly. You can both get the current value of any ScopedRef
, as well as set it to a new value (which may require new resources). The reference itself takes care of properly releasing resources for the old value whenever a new value is obtained.
Signature
export interface ScopedRef<in out A> extends Effect.Effect<A>, ScopedRef.Variance<A>, Pipeable {
/** @internal */
readonly ref: Synchronized.SynchronizedRef<readonly [Scope.Scope.Closeable, A]>
readonly [Unify.typeSymbol]?: unknown
readonly [Unify.unifySymbol]?: ScopedRefUnify<this>
readonly [Unify.ignoreSymbol]?: ScopedRefUnifyIgnore
}
Added in v2.0.0
ScopedRefUnify (interface)
Signature
export interface ScopedRefUnify<A extends { [Unify.typeSymbol]?: any }> extends Effect.EffectUnify<A> {
ScopedRef?: () => Extract<A[Unify.typeSymbol], ScopedRef<any>>
}
Added in v3.9.0
ScopedRefUnifyIgnore (interface)
Signature
export interface ScopedRefUnifyIgnore extends Effect.EffectUnifyIgnore {
Effect?: true
}
Added in v3.9.0
symbols
ScopedRefTypeId
Signature
export declare const ScopedRefTypeId: typeof ScopedRefTypeId
Added in v2.0.0
ScopedRefTypeId (type alias)
Signature
export type ScopedRefTypeId = typeof ScopedRefTypeId
Added in v2.0.0
utils
ScopedRef (namespace)
Added in v2.0.0
Variance (interface)
Signature
export interface Variance<in out A> {
readonly [ScopedRefTypeId]: {
readonly _A: Types.Invariant<A>
}
}
Added in v2.0.0