com.twitter.util

Var

trait Var[+T] extends AnyRef

Trait Var represents a variable. It is a reference cell which is composable: dependent Vars (derived through flatMap) are recomputed automatically when independent variables change -- they implement a form of self-adjusting computation.

Vars are observed, notifying users whenever the variable changes.

Self Type
Var[T]
Note

There are no well-defined error semantics for Var. Vars are computed lazily, and the updating thread will receive any exceptions thrown while computing derived Vars.

,

Vars do not always perform the minimum amount of re-computation.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Var
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def observe(depth: Int, obs: Observer[T]): Closable

    Concrete implementations of Var implement observe.

    Concrete implementations of Var implement observe. This is called for each toplevel observe. Depths indicate the relative structural depth of the observation, from the frame of reference of the root call to observe. (Each Var derived via flatMap increases the depth.) Depths are used to order the invocation of update callbacks. This is used to ensure that updates proceed in topological order so that every input variable is fully resolved before recomputing a derived variable.

    Attributes
    protected

Concrete 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. lazy val changes: Event[T]

    An Event where changes in Var are emitted.

    An Event where changes in Var are emitted. The current value of this Var is emitted synchronously upon subscription.

    All changes to this Var are guaranteed to be published to the Event.

  6. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. def flatMap[U](f: (T) ⇒ Var[U]): Var[U]

    Create a dependent Var which behaves as f applied to the current value of this Var.

    Create a dependent Var which behaves as f applied to the current value of this Var. FlatMap manages a dynamic dependency graph: the dependent Var is detached and recomputed whenever the outer Var changes, but only if there are any observers. An unobserved Var returned by flatMap will not invoke f

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

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

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

    Definition Classes
    Any
  14. def join[U](other: Var[U]): Var[(T, U)]

  15. def map[U](f: (T) ⇒ U): Var[U]

    Create a derived variable by applying f to the contained value.

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

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

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

    Definition Classes
    AnyRef
  19. def sample(): T

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

    Definition Classes
    AnyRef
  21. def toString(): String

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

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def foreach(f: (T) ⇒ Unit): Closable

    Synonymous with observe

    Synonymous with observe

    Annotations
    @deprecated
    Deprecated

    (Since version 6.8.2) Use changes (Event)

  2. final def observe(f: (T) ⇒ Unit): Closable

    Observe this Var.

    Observe this Var. f is invoked each time the variable changes, and synchronously with the first call to this method.

    Annotations
    @deprecated
    Deprecated

    (Since version 6.8.2) Use changes (Event)

  3. def observeTo[U >: T](ref: AtomicReference[U]): Closable

    Observe this Var into the given AtomicReference.

    Observe this Var into the given AtomicReference. Observation stops when the returned closable is closed.

    Annotations
    @deprecated
    Deprecated

    (Since version 6.8.2) Use changes (Event)

  4. def observeUntil(pred: (T) ⇒ Boolean): Future[T]

    A one-shot predicate observation.

    A one-shot predicate observation. The returned future is satisfied with the first observed value of Var that obtains the predicate pred. Observation stops when the future is satisfied.

    Interrupting the future will also satisfy the future (with the interrupt exception) and close the observation.

    Annotations
    @deprecated
    Deprecated

    (Since version 6.8.2) Use changes (Event)

Inherited from AnyRef

Inherited from Any

Ungrouped