FiberRef is a fiber-local variable that provides thread-local-like functionality in Effect. Each fiber has its own isolated value that is inherited by child fibers when they are forked.
Type
FiberRef<A> holds a value of type A that is local to each fiber.
Creating FiberRefs
make
Creates a newFiberRef with an initial value.
make with fork behavior
Creates aFiberRef with custom fork and join behavior.
unsafeMake
Unsafely creates a newFiberRef.
Reading Values
get
Gets the current value of theFiberRef.
getWith
Runs an effect with the current value.Writing Values
set
Sets the value of theFiberRef.
update
Updates the value using a function.modify
Modifies the value and returns a result.getAndSet
Atomically gets the current value and sets a new one.getAndUpdate
Atomically gets the current value and updates it.updateAndGet
Updates the value and returns the new value.Resetting and Deleting
reset
Resets theFiberRef to its initial value.
delete
Deletes the value of theFiberRef.
Built-in FiberRefs
Effect provides several built-inFiberRefs for controlling runtime behavior: