<A>(evaluate: LazyArg<A>): Effect.Effect<ScopedRef<A>, never, Scope.Scope>Creates a new ScopedRef from the specified value.
When to use
Use to create a ScopedRef when the initial value is already available or
can be produced without acquiring resources.
Details
The evaluate function runs when the returned effect runs. The returned
effect requires a Scope, and the reference closes the currently stored
value's scope when that outer scope closes.
Gotchas
Do not use make for an initial value whose creation acquires resources; use
fromAcquire so acquisition and finalization are tracked.
export const const make: <A>(
evaluate: LazyArg<A>
) => Effect.Effect<
ScopedRef<A>,
never,
Scope.Scope
>
Creates a new ScopedRef from the specified value.
When to use
Use to create a ScopedRef when the initial value is already available or
can be produced without acquiring resources.
Details
The evaluate function runs when the returned effect runs. The returned
effect requires a Scope, and the reference closes the currently stored
value's scope when that outer scope closes.
Gotchas
Do not use make for an initial value whose creation acquires resources; use
fromAcquire so acquisition and finalization are tracked.
make = <function (type parameter) A in <A>(evaluate: LazyArg<A>): Effect.Effect<ScopedRef<A>, never, Scope.Scope>A>(evaluate: LazyArg<A>evaluate: import LazyArgLazyArg<function (type parameter) A in <A>(evaluate: LazyArg<A>): Effect.Effect<ScopedRef<A>, never, Scope.Scope>A>): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<interface ScopedRef<in out A>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.
When to use
Use when an application needs to keep a current resource-backed value and
later replace it with another acquired value while ensuring the previous
value is released.
ScopedRef<function (type parameter) A in <A>(evaluate: LazyArg<A>): Effect.Effect<ScopedRef<A>, never, Scope.Scope>A>, never, import ScopeScope.type Scope.Scope = /*unresolved*/ anyScope> =>
import EffectEffect.suspend(() => {
const const scope: Scope.Closeableconst scope: {
strategy: "sequential" | "parallel";
state: State.Open | State.Closed | State.Empty;
}
scope = import ScopeScope.makeUnsafe()
const const value: anyvalue = evaluate: LazyArg<A>evaluate()
const const self: ScopedRef<A>const self: {
backing: Synchronized.SynchronizedRef<readonly [Scope.Closeable, A]>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self = const makeUnsafe: <A>(
scope: Scope.Closeable,
value: A
) => ScopedRef<A>
makeUnsafe(const scope: Scope.Closeableconst scope: {
strategy: "sequential" | "parallel";
state: State.Open | State.Closed | State.Empty;
}
scope, const value: anyvalue)
return import EffectEffect.as(import EffectEffect.addFinalizer((exit: Exit.Exit<unknown, unknown>exit) => import ScopeScope.close(const self: ScopedRef<A>const self: {
backing: Synchronized.SynchronizedRef<readonly [Scope.Closeable, A]>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self.ScopedRef<any>.backing: Synchronized.SynchronizedRef<readonly [Scope.Closeable, A]>(property) ScopedRef<any>.backing: {
backing: Ref.Ref<A>;
semaphore: Semaphore.Semaphore;
ref: MutableRef.MutableRef<A>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
backing.SynchronizedRef<in out A>.backing: Ref.Ref<A>(property) SynchronizedRef<in out A>.backing: {
ref: MutableRef.MutableRef<A>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
backing.ref.current[0], exit: Exit.Exit<unknown, unknown>exit)), const self: ScopedRef<A>const self: {
backing: Synchronized.SynchronizedRef<readonly [Scope.Closeable, A]>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self)
})