effect-io-ai

Package: effect
Module: ScopedRef

ScopedRef.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.

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.

Signature

export interface ScopedRef<in out A> extends Pipeable {
  readonly [TypeId]: typeof TypeId
  readonly backing: Synchronized.SynchronizedRef<readonly [Scope.Closeable, A]>
}

Source

Since v2.0.0