ScopedRef

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

Companion:
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def get(implicit trace: Trace): UIO[A]

Retrieves the current value of the reference.

Retrieves the current value of the reference.

def set[R, E](acquire: ZIO[R & Scope, E, A])(implicit trace: Trace): ZIO[R, E, Unit]

Sets the value of this reference to the specified resourcefully-created value. Any resources associated with the old value will be released.

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.

Concrete methods

def setAsync[R, E](acquire: ZIO[R & Scope, E, A])(implicit trace: Trace): ZIO[R, Nothing, Unit]

The same as ScopedRef#set, but performs the set asynchronously, ignoring failures.

The same as ScopedRef#set, but performs the set asynchronously, ignoring failures.