ZIO<R, E, A> class
Represents an operation that can fail with requirements
Constructors
- ZIO(A f())
-
Create a synchronous ZIO from a function, returning a IO that can't fail.
factory
-
ZIO.async(void f(AsyncContext<
E, A> resume)) -
factory
-
ZIO.asyncInterrupt(IO<
Unit> f(AsyncContext<E, A> $)) -
factory
- ZIO.die(dynamic defect)
-
Create a ZIO that fails with the given defect.
factory
-
ZIO.Do(DoFunction<
R, E, A> f) -
Do notation for ZIO. You can use async/await to write your code in a
imperative style.
factory
- ZIO.envWith(A f(R env))
-
Retrieve the current environment of the ZIO and pass it to the given
function, returning the result.
factory
-
ZIO.envWithZIO(ZIO<
NoEnv, E, A> f(R env)) -
Retrieve the current environment of the ZIO and pass it to the given
function, returning the result of the resulting ZIO.
factory
- ZIO.fail(E e)
-
Create a ZIO that fails with
e
.factory -
ZIO.failCause(Cause<
E> cause) -
Create a ZIO that fails with the given
cause
.factory -
ZIO.from(FutureOr<
Exit< run(ZIOContext<E, A> >R> ctx)) -
Creates a ZIO from a function that takes a ZIOContext and returns a FutureOr of Exit
factory
-
ZIO.fromEither(Either<
E, A> ea) -
Create a ZIO from the given Either, succeeding when it is a Right,
and failing when it is a Left.
factory
-
ZIO.fromExit(Exit<
E, A> ea) -
Create a ZIO from the given Exit.
factory
- ZIO.fromNullableOrFail(A? a, E onNull())
-
Create a EIO from the given nullable value, succeeding when it is not
null, and failing with the result of
onNull
when it is null.factory -
ZIO.fromOptionOrFail(Option<
A> oa, E onNone()) -
Create a EIO from the given Option, succeeding when it is a Some,
and failing with the result of
onNone
when it is a None.factory -
ZIO.future(FutureOr<
A> f()) -
Creates a ZIO from a Future.
factory
-
ZIO.layer(Layer<
E, A> layer) -
Access a Layer and return the resulting service.
If the Layer has already been accessed or provided with provideLayer,
the cached value will be used.
factory
-
ZIO.lazy(ZIO<
R, E, A> zio()) -
Create a ZIO lazily with the given function.
Useful for when you need to create a ZIO from a synchronous side-effect.
factory
-
ZIO.raceAll(Iterable<
ZIO< others)R, E, A> > -
factory
- ZIO.succeed(A a)
-
Create a ZIO that succeeds with
a
.factory -
ZIO.syncEither(Either<
E, A> f()) -
Create a EIO from the resulting Either, succeeding when it is a Right,
and failing with the Left value when it is a Left.
factory
-
ZIO.syncExit(Exit<
E, A> f()) -
Create a EIO from the resulting Exit value;
factory
-
ZIO.tryCatch(FutureOr<
A> f(), E onError(dynamic error, StackTrace stackTrace)) -
Create a EIO from the given function
f
, which may throw an exception.factory -
ZIO.tryCatchEnv(FutureOr<
A> f(R env), E onError(dynamic error, StackTrace stackTrace)) -
A variant of ZIO.tryCatch that provides the current environment
R
to the functionf
.factory
Properties
-
asUnit
→ ZIO<
R, E, Unit> -
Maps the success value of this ZIO to unit.
no setter
-
either
→ RIO<
R, Either< E, A> > -
Squashes the error and success channels into a single
Either
result.no setter -
forever
→ ZIO<
R, E, Never> -
Executes the ZIO in a loop forever, until it fails.
no setter
-
getOrNull
→ RIO<
R, A?> -
Succeed with the value of this ZIO if it succeeds, or succeed with
null
if it fails.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
-
ignore
→ RIO<
R, Unit> -
Ignore both the success and failure values of this ZIO.
no setter
-
ignoreLogged
→ RIO<
R, Unit> -
Ignore both the success and failure values of this ZIO, and log any
failure using logInfo.
no setter
-
logged
→ ZIO<
R, E, A> -
Log any failures using logInfo.
no setter
-
memoize
→ IO<
ZIO< R, E, A> > -
Memoize the result of this
ZIO
in a Deferred.no setter -
microtask
→ ZIO<
R, E, A> -
Force a synchronous ZIO to run asynchronously.
no setter
-
option
→ RIOOption<
R, A> -
no setter
-
orDie
→ RIO<
R, A> -
If the ZIO fails, turn the failure into a defect.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stackTrace → StackTrace?
-
final
Methods
-
always(
ZIO< R, E, A> zio) → ZIO<R, E, A> - Always run the given ZIO after this one, regardless of success or failure.
-
alwaysIgnore<
X> (ZIO< R, E, X> zio) → ZIO<R, E, A> - Always run the given ZIO after this one, regardless of success or failure.
-
annotate(
Symbol key, String name, dynamic value) → ZIO< R, E, A> - Adds an annotation to the the current ZIOContext, which can be retrieved later with annotations.
-
annotateLog(
String name, dynamic value) → ZIO< R, E, A> - Adds an annotation to the next log entry.
-
as<
B> (B b) → ZIO< R, E, B> -
Maps the success value of this ZIO to the given constant
b
. -
catchCause<
E2> (ZIO< R, E2, A> f(Cause<E> _)) → ZIO<R, E2, A> - Catch all defects that may occur on this ZIO. The result will be replaced by executing the ZIO resulting from the given function.
-
catchDefect<
E2> (ZIO< R, E2, A> f(Defect<E> _)) → ZIO<R, E2, A> - Catch any Defect's that may occur on this ZIO. The result will be replaced by executing the ZIO resulting from the given function.
-
catchError<
E2> (ZIO< R, E2, A> f(E _)) → ZIO<R, E2, A> - Catch any errors that may occur on this ZIO. The result will be replaced by executing the ZIO resulting from the given function.
-
delay(
Duration duration) → ZIO< R, E, A> -
Delay the evaluation of this ZIO by the given
duration
. -
filterOrFail(
bool predicate(A _), E onFalse(A _)) → ZIO< R, E, A> -
Filters the success value of this ZIO with the given
predicate
, failing withonFalse
if the predicate fails. -
flatMap<
B> (ZIO< R, E, B> f(A _)) → ZIO<R, E, B> - Passes the success value of this ZIO to the given function, and replaces the result by executing the resulting ZIO.
-
flatMap2<
B> (ZIO< R, E, B> f(A _)) → ZIO<R, E, (A, B)> - A variant of flatMap that zip's the result of this ZIO with the result of the given ZIO, returning a record of the results.
-
flatMapEither<
B> (Either< E, B> f(A _)) → ZIO<R, E, B> - A variant of flatMap that uses the resulting Either to determine the result.
-
flatMapEnv<
B> (ZIO< R, E, B> f(A _, R env)) → ZIO<R, E, B> - A variant of flatMap that also provides the environment to the given function.
-
flatMapNullableOrFail<
B> (B? f(A _), E onNull(A _)) → ZIO< R, E, B> - A variant of flatMap that determines the result of the ZIO by evaluating the resulting nullable value.
-
flatMapOptionOrFail<
B> (Option< B> f(A _), E onNone(A _)) → ZIO<R, E, B> - A variant of flatMap that uses the resulting Option to determine the result.
-
flatMapThrowable<
B> (FutureOr< B> f(A _), E onThrow(dynamic error, StackTrace stack)) → ZIO<R, E, B> -
A variant of flatMap that uses the result of the given function. If the given
function throws an error, the resulting ZIO will fail with the result of
onThrow
. -
flatMapThrowableEnv<
B> (FutureOr< B> f(A _, R env), E onThrow(dynamic error, StackTrace stack)) → ZIO<R, E, B> - A variant of flatMapThrowable, that also provides the environment to the given function.
-
getOrElse(
A orElse(E _)) → RIO< R, A> - Succeed with the value of this ZIO if it succeeds, or succeed with the result of the given function if it fails.
-
logOrElse(
A orElse(E _)) → RIO< R, A> - Succeed with the value of this ZIO if it succeeds, or succeed with the result of the given function if it fails.
-
map<
B> (B f(A _)) → ZIO< R, E, B> - Transform the success value of this ZIO using the given function.
-
mapError<
E2> (E2 f(E _)) → ZIO< R, E2, A> - Transform the failure value of this ZIO using the given function.
-
match<
E2, B> (ZIO< R, E2, B> onError(E _), ZIO<R, E2, B> onSuccess(A _)) → ZIO<R, E2, B> - Reduce the success and error values of this ZIO using the given functions.
-
matchSync<
B> (B onError(E _), B onSuccess(A _)) → RIO< R, B> - A synchronous version of match.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
provide(
R env) → EIO< E, A> -
Provide the ZIO with its required environment, which eliminates its
dependency on
R
. -
provideLayer(
Layer< E, dynamic> layer) → ZIO<R, E, A> - Provide the ZIO with a Layer, building it and adding it into the context.
-
provideLayerContext(
LayerContext context) → ZIO< R, E, A> -
provideService<
S> (Layer< dynamic, S> layer) → ZIO<R, E, A> Function(S service) -
Provide the ZIO with a Layer, using the provided pre-built service
S
. -
race(
ZIO< R, E, A> other) → ZIO<R, E, A> -
repeat<
O> (Schedule< R, E, A, O> schedule) → ZIO<R, E, A> - Repeat this ZIO using the given Schedule.
-
repeatN(
int n) → ZIO< R, E, A> -
Repeat this ZIO
n
times. -
repeatWhile(
bool predicate(A _)) → ZIO< R, E, A> - Repeat this ZIO while the given predicate is true.
-
retry<
O> (Schedule< R, E, E, O> schedule) → ZIO<R, E, A> - Retry this ZIO if it fails using the given Schedule.
-
retryN(
int n) → ZIO< R, E, A> -
Retry (repeat on failure) this ZIO
n
times. -
retryWhile(
bool predicate(E _)) → ZIO< R, E, A> - Retry this ZIO when it fails while the given predicate is true.
-
tap<
X> (ZIO< R, E, X> f(A _)) → ZIO<R, E, A> - Like flatMap, but the result of the resulting ZIO is discarded.
-
tapEither<
X> (ZIO< R, E, X> f(Either<E, A> _)) → ZIO<R, E, A> - A variant of tap, where the success and failure channels are merged into an Either.
-
tapEnv<
X> (ZIO< R, E, X> f(A _, R env)) → ZIO<R, E, A> - A variant of tap, where the current environment is passed to the function.
-
tapError<
X> (ZIO< R, E, X> f(E _)) → ZIO<R, E, A> - Like catchError, but the result of the resulting ZIO is discarded.
-
tapErrorCause<
X> (ZIO< R, E, X> f(Cause<E> _)) → ZIO<R, E, A> - Like catchCause, but the result of the resulting ZIO is discarded.
-
tapExit<
X> (ZIO< R, E, X> f(Exit<E, A> _)) → ZIO<R, E, A> - A variant of tap, passing the Exit value of this ZIO.
-
timeout(
Duration duration) → ZIO< R, E, A> -
toString(
) → String -
A string representation of this object.
inherited
-
unsafeRun(
ZIOContext< R> ctx) → FutureOr<Exit< E, A> > - Run the ZIO with the provided ZIOContext.
-
withRuntime(
Runtime runtime) → ZIO< R, E, A> - Replace the Runtime in this ZIO with the given Runtime.
-
zip<
B> (ZIO< R, E, B> zio) → ZIO<R, E, (A, B)> - Combine the result of this ZIO with the result of the given ZIO, returning a tuple of the results.
-
zipLeft<
X> (ZIO< R, E, X> zio) → ZIO<R, E, A> - Run this ZIO and the given ZIO sequentially, ignoring the result of the given ZIO.
-
zipPar<
B> (ZIO< R, E, B> zio) → ZIO<R, E, (A, B)> - Combine the result of this ZIO with the result of the given ZIO, returning a tuple of the results.
-
zipParLeft<
B> (ZIO< R, E, B> zio) → ZIO<R, E, A> - Run this ZIO and the given ZIO in parallel, ignoring the result of the given ZIO.
-
zipParRight<
B> (ZIO< R, E, B> zio) → ZIO<R, E, B> - Run this ZIO and the given ZIO in parallel, only returning the result of the given ZIO.
-
zipParWith<
B, C> (ZIO< R, E, B> zio, C resolve(A a, B b)) → ZIO<R, E, C> - Combine the result of this ZIO with the result of the given ZIO, using the given function to determine the result.
-
zipRight<
B> (ZIO< R, E, B> zio) → ZIO<R, E, B> - Run this ZIO and the given ZIO sequentially, only returning the result of the given ZIO.
-
zipWith<
B, C> (ZIO< R, E, B> zio, C resolve(A a, B b)) → ZIO<R, E, C> - Combine the result of this ZIO with the result of the given ZIO, using the given function to determine the result.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
Static Methods
-
annotations<
R, E> (Symbol key) → ZIO< R, E, IMap< String, dynamic> > - Retrieves and clears the annotations for the provided key.
-
annotationsIO(
Symbol key) → IO< IMap< String, dynamic> > - IO version of annotations.
-
collect<
R, E, A> (Iterable< ZIO< zios) → ZIO<R, E, A> >R, E, IList< A> > -
Runs the given
zios
in sequence, collecting the results. -
collectDiscard<
R, E, A> (Iterable< ZIO< zios) → ZIO<R, E, A> >R, E, Unit> -
Runs the given
zios
in sequence, discarding the results. -
collectPar<
R, E, A> (Iterable< ZIO< zios) → ZIO<R, E, A> >R, E, IList< A> > -
Runs the given
zios
in parallel, collecting the results. -
collectParDiscard<
R, E, A> (Iterable< ZIO< zios) → ZIO<R, E, A> >R, E, Unit> -
Runs the given
zios
in parallel, discarding the results. -
env<
R> () → RIO< R, R> - Retrieve the current environment of the ZIO.
-
fromNullable<
A> (A? a) → IOOption< A> -
Create an IOOption from the given nullable value, succeeding when it is
not null, and failing with
None
when it is null. -
fromOption<
A> (Option< A> oa) → IOOption<A> -
Create an IOOption from the given Option, succeeding when it is a
Some, and failing with
None
when it is aNone
. -
log<
R, E> (LogLevel level, Object? message, {Map< String, dynamic> ? annotations}) → ZIO<R, E, Unit> - Log a message using the Logger service. It uses the loggerLayer to access the Logger.
-
logDebug<
R, E> (Object? message, {Map< String, dynamic> ? annotations}) → ZIO<R, E, Unit> - Log a message at the LogLevel.debug level using the Logger service.
-
logDebugIO(
Object? message, {Map< String, dynamic> ? annotations}) → IO<Unit> - An IO version of logDebug.
-
logError<
R, E> (Object? message, {Map< String, dynamic> ? annotations}) → ZIO<R, E, Unit> - Log a message at the LogLevel.error level using the Logger service.
-
logErrorIO(
Object? message, {Map< String, dynamic> ? annotations}) → IO<Unit> - An IO version of logError.
-
logInfo<
R, E> (Object? message, {Map< String, dynamic> ? annotations}) → ZIO<R, E, Unit> - Log a message at the LogLevel.info level using the Logger service.
-
logInfoIO(
Object? message, {Map< String, dynamic> ? annotations}) → IO<Unit> - An IO version of logInfo.
-
logIO(
LogLevel level, Object? message) → IO< Unit> - An IO version of log.
-
logWarn<
R, E> (Object? message, {Map< String, dynamic> ? annotations}) → ZIO<R, E, Unit> - Log a message at the LogLevel.warn level using the Logger service.
-
logWarnIO(
Object? message, {Map< String, dynamic> ? annotations}) → IO<Unit> - An IO version of logWarn.
-
runtime<
R, E> () → ZIO< R, E, Runtime> -
Access the current
Runtime
. -
sleep<
R, E> (Duration duration) → ZIO< R, E, Unit> -
Sleep for the given
duration
. -
sleepIO(
Duration duration) → IO< Unit> - An IO version of sleep.
-
traverseIterable<
R, E, A, B> (Iterable< A> iterable, ZIO<R, E, B> f(A _)) → ZIO<R, E, IList< B> > - Traverse an Iterable with the given function, collecting the results.
-
traverseIterablePar<
R, E, A, B> (Iterable< A> iterable, ZIO<R, E, B> f(A _)) → ZIO<R, E, IList< B> > - Traverse an Iterable with the given function, collecting the results in parallel.
-
tryCatchNullable<
A> (FutureOr< A?> f()) → IOOption<A> -
tryCatchOption<
A> (FutureOr< A> f()) → IOOption<A> - A variant of ZIO.tryCatch, that returns an IOOption instead of an EIO.
-
unit<
R, E> () → ZIO< R, E, Unit> - Returns a ZIO that succeeds with unit.