ScopedRef

zio.ScopedRef
See theScopedRef companion object
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.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

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.

Attributes

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 the old resources are released and either the reference is successfully changed to the new value or the attempt to acquire a new value fails.

Attributes

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.

Attributes