Creates a new task that upon execution will return the result of the first task that completes, while canceling the other.
Returns a task that waits for the specified timespan
before
executing and mirroring the result of the source.
Returns a task that waits for the specified trigger
to succeed
before mirroring the result of the source.
Returns a task that waits for the specified trigger
to succeed
before mirroring the result of the source.
If the trigger
ends in error, then the resulting task will also
end in error.
Returns a task that executes the source immediately on runAsync
,
but before emitting the onSuccess
result for the specified
duration.
Returns a task that executes the source immediately on runAsync
,
but before emitting the onSuccess
result for the specified
duration.
Note that if an error happens, then it is streamed immediately with no delay.
Returns a task that executes the source immediately on runAsync
,
but before emitting the onSuccess
result for the specified
duration.
Returns a task that executes the source immediately on runAsync
,
but before emitting the onSuccess
result for the specified
duration.
Note that if an error happens, then it is streamed immediately with no delay.
Returns a failed projection of this task.
Returns a failed projection of this task.
The failed projection is a future holding a value of type
Throwable
, emitting a value which is the throwable of the
original task in case the original task fails, otherwise if the
source succeeds, then it fails with a NoSuchElementException
.
Creates a new Task by applying a function to the successful result of the source Task, and returns a task equivalent to the result of the function.
Given a source Task that emits another Task, this function flattens the result, returning a Task equivalent to the emitted Task by the source.
Lifts the source into one that exposes possible errors.
Returns a new Task that applies the mapping function to the element emitted by the source.
Creates a new task that in case of error will fallback to the given backup task.
Creates a new task that will handle any matching throwable that this task might emit.
Creates a new task that will handle any matching throwable that this task might emit by executing another task.
Creates a new task that in case of error will retry executing the source again and again, until it succeeds.
Creates a new task that in case of error will retry executing the source again and again, until it succeeds.
In case of continuous failure the total number of executions
will be maxRetries + 1
.
Creates a new task that in case of error will retry executing the source again and again, until it succeeds.
Creates a new task that in case of error will retry executing the source again and again, until it succeeds.
In case of continuous failure the total number of executions
will be maxRetries + 1
.
Triggers the asynchronous execution.
Triggers the asynchronous execution.
a CancelableFuture that can be used to extract the result or to cancel a running task.
Triggers the asynchronous execution.
Triggers the asynchronous execution.
is a callback that will be invoked upon completion.
a Cancelable that can be used to cancel a running task
Triggers the asynchronous execution.
Triggers the asynchronous execution.
is a callback that will be invoked upon completion.
a Cancelable that can be used to cancel a running task
Returns a Task that mirrors the source Task but that triggers a
TimeoutException
in case the given duration passes without the
task emitting any item.
Returns a Task that mirrors the source Task but switches to the given backup Task in case the given duration passes without the source emitting any item.
Zips the values of this
and that
task, and creates a new task
that will emit the tuple of their results.
Task
represents a specification for an asynchronous computation, which when executed will produce anA
as a result, along with possible side-effects.Compared with
Future
from Scala's standard library,Task
does not represent a running computation or a value detached from time, asTask
does not execute anything when working with its builders or operators and it does not submit any work into any thread-pool, the execution eventually taking place only afterrunAsync
is called and not before that.Note that
Task
is conservative in how it spawns logical threads. Transformations likemap
andflatMap
for example will default to being executed on the logical thread on which the asynchronous computation was started. But one shouldn't make assumptions about how things will end up executed, as ultimately it is the implementation's job to decide on the best execution model. All you are guaranteed is asynchronous execution after executingrunAsync
.