Packages

case class Activity[+T](run: Var[State[T]]) extends Product with Serializable

Activity, like Var, is a value that varies over time; but, richer than Var, these values have error and pending states. They are useful for modeling a process that produces values, but also intermittent failures (e.g. address resolution, reloadable configuration).

As such, an Activity can be in one of three states:

  • Pending: output is pending;
  • Ok: an output is available; and
  • Failed: the process failed with an exception.

An Activity may transition between any state at any time. They are typically constructed from Events, but they can also be constructed without arguments.

val (activity, witness) = Activity[Int]()
println(activity.sample()) // throws java.lang.IllegalStateException: Still pending

As you can see, Activities start in a Pending state. Attempts to sample an Activity that is pending will fail. Curiously, the constructor for an Activity also returns a Witness.

Recall that a Witness is the interface to something that you can send values to; and in this case, that something is the Activity.

witness.notify(Return(1))
println(activity.sample()) // prints 1

(For implementers, it may be useful to think of Activity as a monad transformer for an Op monad over Var where Op is like a Try with an additional pending state.)

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Activity
  2. Serializable
  3. Product
  4. Equals
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Activity(run: Var[State[T]])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. def collect[U](f: PartialFunction[T, U]): Activity[U]

    Build a new activity by applying f to each value.

    Build a new activity by applying f to each value. When f is not defined for this activity's current value, the derived activity becomes pending.

  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  9. def flatMap[U](f: (T) => Activity[U]): Activity[U]

    The activity which behaves as f applied to Ok values.

  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def handle[U >: T](h: PartialFunction[Throwable, U]): Activity[U]

    Recover a failed activity.

  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. def join[U](that: Activity[U]): Activity[(T, U)]

    Join two activities.

  14. def map[U](f: (T) => U): Activity[U]

    Map a T-typed activity to a U-typed one.

  15. def mapState[U](f: (State[T]) => State[U]): Activity[U]

    Map the states of a T-typed activity to a U-typed one.

  16. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. def productElementNames: Iterator[String]
    Definition Classes
    Product
  20. val run: Var[State[T]]
  21. def sample(): T

    Sample the current value of this activity.

    Sample the current value of this activity. Sample throws an exception if the activity is in pending state or has failed.

  22. def stabilize: Activity[T]

    Stabilize the value of this activity such that once an Ok value has been returned it stops error propagation and instead returns the last Ok value.

  23. def states: Event[State[T]]

    An Event of states.

  24. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  25. def transform[U](f: (State[T]) => Activity[U]): Activity[U]

    The activity which behaves as f to the state of this activity.

  26. def values: Event[Try[T]]

    An Event containing only nonpending values.

  27. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  28. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  29. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped