monix.async

Task

sealed abstract class Task[+A] extends AnyRef

Task represents a specification for an asynchronous computation, which when executed will produce an A 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, as Task 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 after runAsync is called and not before that.

Note that Task is conservative in how it spawns logical threads. Transformations like map and flatMap 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 executing runAsync.

Self Type
Task[A]
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Task
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Task()

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def ambWith[B >: A](other: Task[B]): Task[B]

    Creates a new task that upon execution will return the result of the first task that completes, while canceling the other.

  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def delayExecution(timespan: FiniteDuration): Task[A]

    Returns a task that waits for the specified timespan before executing and mirroring the result of the source.

  10. def delayExecutionWith(trigger: Task[Any]): Task[A]

    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.

  11. def delayResult(timespan: FiniteDuration): Task[A]

    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.

  12. def delayResultBySelector[B](selector: (A) ⇒ Task[B]): Task[A]

    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.

  13. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  14. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  15. def failed: Task[Throwable]

    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.

  16. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. def flatMap[B](f: (A) ⇒ Task[B]): Task[B]

    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.

  18. def flatten[B](implicit ev: <:<[A, Task[B]]): Task[B]

    Given a source Task that emits another Task, this function flattens the result, returning a Task equivalent to the emitted Task by the source.

  19. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  20. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  21. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  22. def liftTry: Task[Try[A]]

    Lifts the source into one that exposes possible errors.

  23. def map[B](f: (A) ⇒ B): Task[B]

    Returns a new Task that applies the mapping function to the element emitted by the source.

  24. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  25. final def notify(): Unit

    Definition Classes
    AnyRef
  26. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  27. def onErrorFallbackTo[B >: A](that: ⇒ Task[B]): Task[B]

    Creates a new task that in case of error will fallback to the given backup task.

  28. def onErrorRecover[U >: A](pf: PartialFunction[Throwable, U]): Task[U]

    Creates a new task that will handle any matching throwable that this task might emit.

  29. def onErrorRecoverWith[B >: A](pf: PartialFunction[Throwable, Task[B]]): Task[B]

    Creates a new task that will handle any matching throwable that this task might emit by executing another task.

  30. def onErrorRetry(maxRetries: Long): Task[A]

    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.

  31. def onErrorRetryIf(p: (Throwable) ⇒ Boolean): Task[A]

    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.

  32. def runAsync(implicit s: Scheduler): CancelableFuture[A]

    Triggers the asynchronous execution.

    Triggers the asynchronous execution.

    returns

    a CancelableFuture that can be used to extract the result or to cancel a running task.

  33. def runAsync(f: (Try[A]) ⇒ Unit)(implicit s: Scheduler): Cancelable

    Triggers the asynchronous execution.

    Triggers the asynchronous execution.

    f

    is a callback that will be invoked upon completion.

    returns

    a Cancelable that can be used to cancel a running task

  34. def runAsync(cb: Callback[A])(implicit s: Scheduler): Cancelable

    Triggers the asynchronous execution.

    Triggers the asynchronous execution.

    cb

    is a callback that will be invoked upon completion.

    returns

    a Cancelable that can be used to cancel a running task

  35. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  36. def timeout(after: FiniteDuration): Task[A]

    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.

  37. def timeoutTo[B >: A](after: FiniteDuration, backup: ⇒ Task[B]): Task[B]

    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.

  38. def toString(): String

    Definition Classes
    AnyRef → Any
  39. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  40. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  41. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  42. def zip[B](that: Task[B]): Task[(A, B)]

    Zips the values of this and that task, and creates a new task that will emit the tuple of their results.

Inherited from AnyRef

Inherited from Any

Ungrouped