Class/Object

mhtml

Var

Related Docs: object Var | package mhtml

Permalink

class Var[A] extends Rx[A]

A smart variable that can be set manually.

Linear Supertypes
Rx[A], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Var
  2. Rx
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Var(initialValue: Option[A], register: (Var[A]) ⇒ Cancelable)

    Permalink

Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def :=(newValue: A): Unit

    Permalink

    Sets the value of this Var.

    Sets the value of this Var. Triggers recalculation of depending Rxs.

  4. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. def collect[B](f: PartialFunction[A, B])(b: B): Rx[B]

    Permalink

    Returns a new Rx with updates where f is defined and mapped by f.

    Returns a new Rx with updates where f is defined and mapped by f. If the first update is dropped, the default value is used instead.

    Definition Classes
    Rx
  8. def dropIf[B >: A](f: (B) ⇒ Boolean)(b: B): Rx[B]

    Permalink

    Returns a new Rx without updates fulfilling a predicate.

    Returns a new Rx without updates fulfilling a predicate. If the first update is dropped, the default value is used instead.

    val numbers: Rx[Int] val even: Rx[Int] = numbers.dropIf(_ % 2 == 0)(-1) // numbers => 0 0 3 4 5 6 ... // even => -1 3 5 ...

    Definition Classes
    Rx
  9. def dropRepeats: Rx[A]

    Permalink

    Drop repeated value of this Rx.

    Drop repeated value of this Rx.

    val numbers: Rx[Int] val noDups: Rx[Int] = numbers.dropRepeats // numbers => 0 0 3 3 5 5 5 4 ... // noDups => 0 3 5 4 ...

    Note: This could also be implemented in terms of keepIf, map, and foldp.

    Definition Classes
    Rx
  10. final def eq(arg0: AnyRef): Boolean

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

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

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

    Permalink

    Dynamically switch between different Rxs according to the given function, applied on each element of this Rx.

    Dynamically switch between different Rxs according to the given function, applied on each element of this Rx. Each switch will cancel the subscriptions for the previous outgoing Rx and start a new subscription on the next Rx.

    Together with Rx#map and Rx.apply, flatMap forms a Monad. [Proof](https://github.com/OlivierBlanvillain/monadic-html/blob/master/monadic-rx-cats/src/main/scala/mhtml/cats.scala).

    Definition Classes
    Rx
  14. def foldp[B](seed: B)(step: (B, A) ⇒ B): Rx[B]

    Permalink

    Produces a Rx containing cumulative results of applying a binary operator to each element of this Rx, starting from a seed and the current value of the upstream Rx, and moving forward in time; no internal state is maintained.

    Produces a Rx containing cumulative results of applying a binary operator to each element of this Rx, starting from a seed and the current value of the upstream Rx, and moving forward in time; no internal state is maintained.

    val numbers: Rx[Int] val folded: Rx[Int] = numbers.foldp(0)(_ + _) // numbers => 1 2 1 1 3 ... // folded => 1 3 4 5 8 ...

    Definition Classes
    Rx
  15. final def getClass(): Class[_]

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

    Permalink
    Definition Classes
    AnyRef → Any
  17. def imitate(other: Rx[A]): Rx[A]

    Permalink

    Updates this Var with values emitted by the other Rx.

    Updates this Var with values emitted by the other Rx. This method is side effect free. Consequently, the returned Rx must be used at least once for the imitation to take place. This Var the other Rx and the returned Rx will all emit the same values.

    This method exists (only) to allow *circular dependency* in Rx graphs.

  18. val impure: RxImpureOps[A]

    Permalink
    Definition Classes
    Rx
  19. def isCold: Boolean

    Permalink

    Is there anything currently subscribed to this Var?

    Is there anything currently subscribed to this Var?

    This method is intended to be used to test the absence of memory leak. For instance, all Vars should be cold after canceling a mount.

  20. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  21. def keepIf[B >: A](f: (B) ⇒ Boolean)(b: B): Rx[B]

    Permalink

    Returns a new Rx with updates fulfilling a predicate.

    Returns a new Rx with updates fulfilling a predicate. If the first update is dropped, the default value is used instead.

    val numbers: Rx[Int] val even: Rx[Int] = numbers.keepIf(_ % 2 == 0)(-1) // numbers => 0 0 3 4 5 6 ... // even => 0 0 4 6 ...

    Definition Classes
    Rx
  22. def map[B](f: (A) ⇒ B): Rx[B]

    Permalink

    Apply a function to each element of this Rx.

    Apply a function to each element of this Rx.

    val numbers: Rx[Int] val doubles: Rx[Int] = numbers.map(2.*) // numbers => 0 1 4 3 2 ... // doubles => 0 2 8 6 4 ...

    Definition Classes
    Rx
  23. def merge[B >: A](other: Rx[B]): Rx[B]

    Permalink

    Merge two Rx into one.

    Merge two Rx into one. Updates coming from either of the incoming Rx trigger updates in the outgoing Rx. Upon creation, the outgoing Rx first receives the current value from this Rx, then from the other Rx.

    val r1: Rx[Int] val r2: Rx[Int] val merged: Rx[Int] = r1.merge(r2) // r1 => 0 8 3 ... // r2 => 1 4 3 ... // merged => 0 8 4 3 3 ...

    With this operation, Rx forms a Semigroup. [Proof](https://github.com/OlivierBlanvillain/monadic-html/blob/master/monadic-rx-cats/src/main/scala/mhtml/cats.scala). |+| syntax is available via the monadic-rx-cats package.

    Definition Classes
    Rx
  24. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  27. def sampleOn[B](other: Rx[B]): Rx[A]

    Permalink

    Sample this Rx using another Rx: every time an event occurs on the second Rx the output updates with the latest value of this Rx.

    Sample this Rx using another Rx: every time an event occurs on the second Rx the output updates with the latest value of this Rx.

    val r1: Rx[Char] val r2: Rx[Int] val sp: Rx[Int] = r2.sampleOn(r1) // r1 => u u u u ... // r2 => 1 2 3 4 ... // sp => 1 3 3 4 ...

    Definition Classes
    Rx
  28. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  29. def toString(): String

    Permalink
    Definition Classes
    Var → AnyRef → Any
  30. def update(f: (A) ⇒ A): Unit

    Permalink

    Updates the value of this Var.

    Updates the value of this Var. Triggers recalculation of depending Rxs.

  31. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. def zip[B](other: Rx[B]): Rx[(A, B)]

    Permalink

    Create the Cartesian product of two Rx.

    Create the Cartesian product of two Rx. The output tuple contains the latest values from each input Rx, which updates whenever the value from either input Rx update. This method is faster than combining Rxs using for { a <- ra; b <- rb } yield (a, b).

    // r1 => 0 8 9 ... // r2 => 1 4 5 6 ... // zip => (0,1) (8,1) (8,4) (8,5) (8,6) (9,6) ...

    This method, together with Rx.apply, forms am Applicative. |@| syntax is available via the monadic-rx-cats package.

    Definition Classes
    Rx

Deprecated Value Members

  1. def product[B](other: Rx[B]): Rx[(A, B)]

    Permalink
    Definition Classes
    Rx
    Annotations
    @deprecated
    Deprecated

    (Since version 0.3.3) Renamed to zip

Inherited from Rx[A]

Inherited from AnyRef

Inherited from Any

Ungrouped