Folds over the error and value types of the ZFiberRef
.
Folds over the error and value types of the ZFiberRef
. This is a highly
polymorphic method that is capable of arbitrarily transforming the error
and value types of the ZFiberRef
. For most use cases one of the more
specific combinators implemented in terms of fold
will be more ergonomic
but this method is extremely useful for implementing new combinators.
Folds over the error and value types of the ZFiberRef
, allowing access
to the state in transforming the set
value.
Folds over the error and value types of the ZFiberRef
, allowing access
to the state in transforming the set
value. This is a more powerful
version of fold
but requires unifying the error types.
Reads the value associated with the current fiber.
Reads the value associated with the current fiber. Returns initial value if
no value was set
or inherited from parent.
Returns an IO
that runs with value
bound to the current fiber.
Returns an IO
that runs with value
bound to the current fiber.
Guarantees that fiber data is properly restored via acquireRelease
.
Sets the value associated with the current fiber.
Maps and filters the get
value of the ZFiberRef
with the specified
partial function, returning a ZFiberRef
with a get
value that succeeds
with the result of the partial function if it is defined or else fails
with None
.
Transforms the set
value of the ZFiberRef
with the specified function.
Transforms the set
value of the ZFiberRef
with the specified fallible
function.
Transforms both the set
and get
values of the ZFiberRef
with the
specified functions.
Transforms both the set
and get
values of the ZFiberRef
with the
specified fallible functions.
Transforms both the set
and get
errors of the ZFiberRef
with the
specified functions.
Filters the set
value of the ZFiberRef
with the specified predicate,
returning a ZFiberRef
with a set
value that succeeds if the predicate
is satisfied or else fails with None
.
Filters the get
value of the ZFiberRef
with the specified predicate,
returning a ZFiberRef
with a get
value that succeeds if the predicate
is satisfied or else fails with None
.
Transforms the get
value of the ZFiberRef
with the specified function.
Transforms the get
value of the ZFiberRef
with the specified fallible
function.
Returns a read only view of the ZFiberRef
.
Returns a write only view of the ZFiberRef
.
A
FiberRef
is ZIO's equivalent of Java'sThreadLocal
. The value of aFiberRef
is automatically propagated to child fibers when they are forked and merged back in to the value of the parent fiber after they are joined.Here
result
will be equal to "Hi!" since changed made by a child fiber are merged back in to the value of the parent fiber on join.By default the value of the child fiber will replace the value of the parent fiber on join but you can specify your own logic for how values should be merged.
Here
value
will be 2 as the value in the joined fiber is lower and we specifiedmax
as our combining function.