ZIO<R, E, A> class
Represents an operation that can fail with requirements
- Implemented types
-
- IZIO<
R, E, A>
- IZIO<
- Available extensions
Constructors
- ZIO.new(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<
IZIO< 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
-
asZIO
→ ZIO<
R, E, A> -
no setteroverride
-
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
-
forkIO
→ RIO<
R, Fiber< R, E, A> > -
Available on ZIO<
An IO version of fork.R, E, A> , provided by the ZIOForkExt extensionno setter -
forkScopeIO
→ RIO<
R, Fiber< R, E, A> > -
Available on ZIO<
An IO version of fork.R, E, A> , provided by the ZIOFinalizerExt extensionno setter -
forkScopeIO
→ RIO<
Scope< R> , Fiber<R, E, A> > -
Available on ZIO<
An IO version of fork.R, E, A> , provided by the ZIOForkExt extensionno 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
-
option
→ RIO<
R, Option< A> > -
Available on RIOOption<
Transform an IOOption into anR, A> , provided by the ZIONoneExt extensionIO<Option<A>>
.no setter -
orDie
→ RIO<
R, A> -
If the ZIO fails, turn the failure into a defect.
no setter
-
runner
→ IO<
ZIORunner< E, A> > -
Available on EIO<
E, A> , provided by the EIORunnerExt extensionno setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
scoped
→ ZIO<
R, E, A> -
Available on ZIO<
Provide a Scope to this ZIO. All finalizers added to the Scope will be run at this point of the execution.Scope< , provided by the ZIOScopeExt extensionR> , E, A>no setter - stackTrace → StackTrace?
-
final
-
withScope
→ ZIO<
Scope< R> , E, A> -
Available on ZIO<
Wrap the environment of this ZIO in a Scope.R, E, A> , provided by the ZIOFinalizerNoEnvExt extensionno setter
Methods
-
acquireRelease(
IO< Unit> release(A _)) → ZIO<Scope< R> , E, A> -
Available on ZIO<
Request a Scope and add a finalizer from the result of this ZIO to it.R, E, A> , provided by the ZIOFinalizerNoEnvExt extension -
acquireRelease(
IO< Unit> release(A _)) → ZIO<R, E, A> -
Available on ZIO<
Add a finalizer to this ZIO for the current Scope, using the result of this ZIO.R, E, A> , provided by the ZIOFinalizerExt extension -
addFinalizer(
IO< Unit> release) → ZIO<R, E, A> -
Available on ZIO<
Add a finalizer to this ZIO for the current Scope.R, E, A> , provided by the ZIOFinalizerExt extension -
addFinalizer(
IO< Unit> release) → ZIO<Scope< R> , E, A> -
Available on ZIO<
Request a Scope and add a finalizer to it.R, E, A> , provided by the ZIOFinalizerNoEnvExt extension -
always(
IZIO< R, E, A> zio) → ZIO<R, E, A> - Always run the given ZIO after this one, regardless of success or failure.
-
alwaysIgnore<
X> (IZIO< 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
. -
ask<
R> () → ZIO< R, E, A> -
Available on ZIO<
Lift the environment of this ZIO to the givenNoEnv, E, A> , provided by the ZIOAskExt extensionR
type. -
catchCause<
E2> (IZIO< 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> (IZIO< 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> (IZIO< 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
. -
filter(
bool predicate(A _)) → RIOOption< R, A> -
Available on RIOOption<
Filter a IOOption by the given predicate, failing with None if the predicate is not satisfied.R, A> , provided by the ZIONoneExt extension -
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> (IZIO< 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> (IZIO< 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.
-
flatMapEnv<
B> (IZIO< R, E, B> f(A _, R env)) → ZIO<R, E, B> - A variant of flatMap that also provides the environment to the given function.
-
flatMapNullable<
B> (B? f(A _)) → RIOOption< R, B> -
Available on RIOOption<
If the given functionR, A> , provided by the ZIONoneExt extensionf
returnsnull
, fail with None. Otherwise, return the result off
. -
flatMapNullableOrFail<
B> (B? f(A _), E orFailWith(A _)) → ZIO< R, E, B> -
If the given function
f
returnsnull
, fail with the specified error. Otherwise, return the result off
. -
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.
-
fork<
E2> () → ZIO< R, E2, Fiber< R, E, A> > -
Available on ZIO<
Fork this ZIO into a Fiber, running it in the background.R, E, A> , provided by the ZIOForkExt extension -
forkScope<
E2> () → ZIO< Scope< R> , E2, Fiber<R, E, A> > -
Available on ZIO<
Fork this ZIO into a Fiber, running it in the background.R, E, A> , provided by the ZIOForkExt extension -
forkScope<
E2> () → ZIO< R, E2, Fiber< R, E, A> > -
Available on ZIO<
Fork this ZIO into a Fiber, running it in the background.R, E, A> , provided by the ZIOFinalizerExt extension -
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.
-
lift<
R, E> () → ZIO< R, E, A> -
Available on IO<
Lift this IO to a ZIO with the specified environment and error type.A> , provided by the IOLiftExt extension -
lift<
E> () → ZIO< R, E, A> -
Available on RIO<
Lift this RIO to a ZIO with the same environment and error type.R, A> , provided by the RIOLiftExt extension -
lift<
R> () → ZIO< R, E, A> -
Available on EIO<
Lift this EIO to a ZIO with the same error type.E, A> , provided by the EIOLiftExt extension -
liftError<
E2> () → EIO< E2, A> -
Available on EIO<
Lift this EIO to a another EIO with the specified error type.E, A> , provided by the EIOLiftExt extension -
liftError<
E> () → ZIO< R, E, A> -
Available on RIO<
Lift this RIO to a ZIO with the same environment and error type.R, A> , provided by the RIOLiftExt extension -
liftError<
E> () → EIO< E, A> -
Available on IO<
Lift this IO to a EIO with the specified error type.A> , provided by the IOLiftExt extension -
liftScope<
R extends ScopeMixin> () → ZIO< R, E, A> -
Available on ZIO<
Scope< , provided by the ZIOLiftScopeExt extensionNoEnv> , E, A> -
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> (IZIO< R, E2, B> onError(E _), IZIO<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(
IZIO< 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.
-
run(
{Runtime? runtime, DeferredIO< Never> ? interruptionSignal}) → FutureOr<Exit< E, A> > -
Available on EIO<
Runs this ZIO asynchronously or synchronously as a FutureOr, returning the Exit result.E, A> , provided by the ZIORunExt extension -
runFuture(
{Runtime? runtime, DeferredIO< Never> ? interruptionSignal}) → Future<Exit< E, A> > -
Available on EIO<
Runs this ZIO asynchronously and returns the Exit result as a Future.E, A> , provided by the ZIORunExt extension -
runFutureOrThrow(
{Runtime? runtime, DeferredIO< Never> ? interruptionSignal}) → Future<A> -
Available on EIO<
Runs this ZIO asynchronously and returns result as a Future. If the ZIO fails, the Future will throw.E, A> , provided by the ZIORunExt extension -
runOrThrow(
{Runtime? runtime, DeferredIO< Never> ? interruptionSignal}) → FutureOr<A> -
Available on EIO<
Runs this ZIO synchronously or asynchronously as a FutureOr, throwing if it fails.E, A> , provided by the ZIORunExt extension -
runSync(
{Runtime? runtime, DeferredIO< Never> ? interruptionSignal}) → Exit<E, A> -
Available on EIO<
Runs this ZIO synchronously and returns the result as an Exit.E, A> , provided by the ZIORunExt extension -
runSyncOrThrow(
[Runtime? runtime]) → A -
Available on EIO<
Runs this ZIO synchronously and throws if it fails.E, A> , provided by the ZIORunExt extension -
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> (IZIO< 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> (IZIO< 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> (IZIO< 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> (IZIO< R, E, X> zio) → ZIO<R, E, A> - Run this ZIO and the given IZIO sequentially, ignoring the result of the given IZIO.
-
zipPar<
B> (IZIO< 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> (IZIO< 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> (IZIO< 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> (IZIO< 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> (IZIO< R, E, B> zio) → ZIO<R, E, B> - Run this ZIO and the given IZIO sequentially, only returning the result of the given IZIO.
-
zipWith<
B, C> (IZIO< 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< IZIO< zios) → ZIO<R, E, A> >R, E, IList< A> > -
Runs the given
zios
in sequence, collecting the results. -
collectDiscard<
R, E, A> (Iterable< IZIO< zios) → ZIO<R, E, A> >R, E, Unit> -
Runs the given
zios
in sequence, discarding the results. -
collectPar<
R, E, A> (Iterable< IZIO< zios) → ZIO<R, E, A> >R, E, IList< A> > -
Runs the given
zios
in parallel, collecting the results. -
collectParDiscard<
R, E, A> (Iterable< IZIO< 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 a None.
-
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, IZIO<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, IZIO<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.