/** * @since 2.0.0 */ import * as Effect from "./Effect.ts"; import { type LazyArg } from "./Function.ts"; import type { Pipeable } from "./Pipeable.ts"; import * as Scope from "./Scope.ts"; import * as Synchronized from "./SynchronizedRef.ts"; declare const TypeId = "~effect/ScopedRef"; /** * 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. * * @since 2.0.0 * @category models */ export interface ScopedRef extends Pipeable { readonly [TypeId]: typeof TypeId; readonly backing: Synchronized.SynchronizedRef; } /** * Creates a new `ScopedRef` from an effect that resourcefully produces a * value. * * @since 2.0.0 * @category constructors */ export declare const fromAcquire: (acquire: Effect.Effect) => Effect.Effect, E, Scope.Scope | R>; /** * Retrieves the current value of the scoped reference. * * @since 4.0.0 * @category getters */ export declare const getUnsafe: (self: ScopedRef) => A; /** * Retrieves the current value of the scoped reference. * * @since 2.0.0 * @category getters */ export declare const get: (self: ScopedRef) => Effect.Effect; /** * Creates a new `ScopedRef` from the specified value. This method should * not be used for values whose creation require the acquisition of resources. * * @since 2.0.0 * @category constructors */ export declare const make: (evaluate: LazyArg) => Effect.Effect, never, Scope.Scope>; /** * 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. * * @since 2.0.0 * @category getters */ export declare const 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. * * @since 2.0.0 * @category getters */ (acquire: Effect.Effect): (self: ScopedRef) => Effect.Effect>; /** * 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. * * @since 2.0.0 * @category getters */ (self: ScopedRef, acquire: Effect.Effect): Effect.Effect>; }; export {}; //# sourceMappingURL=ScopedRef.d.ts.map