sealed trait Rx[+A] extends AnyRef
Reactive value of type A
. Automatically recalculate on dependency update.
- Self Type
- Rx[A]
- Alphabetic
- By Inheritance
- Rx
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def collect[B](f: PartialFunction[A, B])(b: B): Rx[B]
Returns a new
Rx
with updates wheref
is defined and mapped byf
.Returns a new
Rx
with updates wheref
is defined and mapped byf
. If the first update is dropped, the default value is used instead. - def dropIf[B >: A](f: (B) => Boolean)(b: B): Rx[B]
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 ...
- def dropRepeats: Rx[A]
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.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def flatMap[B](f: (A) => Rx[B]): Rx[B]
Dynamically switch between different
Rx
s according to the given function, applied on each element of thisRx
.Dynamically switch between different
Rx
s according to the given function, applied on each element of thisRx
. Each switch will cancel the subscriptions for the previous outgoingRx
and start a new subscription on the nextRx
.Together with
Rx#map
andRx.apply
, flatMap forms aMonad
. [Proof](https://github.com/OlivierBlanvillain/monadic-html/blob/master/monadic-rx-cats/src/main/scala/mhtml/cats.scala). - def foldp[B](seed: B)(step: (B, A) => B): Rx[B]
Produces a
Rx
containing cumulative results of applying a binary operator to each element of thisRx
, starting from aseed
and the current value of the upstreamRx
, 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 thisRx
, starting from aseed
and the current value of the upstreamRx
, 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 ...
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- val impure: RxImpureOps[A]
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def keepIf[B >: A](f: (B) => Boolean)(b: B): Rx[B]
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 ...
- def map[B](f: (A) => B): Rx[B]
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 ...
- def merge[B >: A](other: Rx[B]): Rx[B]
Merge two
Rx
into one.Merge two
Rx
into one. Updates coming from either of the incomingRx
trigger updates in the outgoingRx
. Upon creation, the outgoingRx
first receives the current value from thisRx
, then from the otherRx
.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 aSemigroup
. [Proof](https://github.com/OlivierBlanvillain/monadic-html/blob/master/monadic-rx-cats/src/main/scala/mhtml/cats.scala).|+|
syntax is available via themonadic-rx-cats
package. - final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def sampleOn[B](other: Rx[B]): Rx[A]
Sample this
Rx
using anotherRx
: every time an event occurs on the secondRx
the output updates with the latest value of thisRx
.Sample this
Rx
using anotherRx
: every time an event occurs on the secondRx
the output updates with the latest value of thisRx
.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 ...
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def zip[B](other: Rx[B]): Rx[(A, B)]
Create the Cartesian product of two
Rx
.Create the Cartesian product of two
Rx
. The output tuple contains the latest values from each inputRx
, which updates whenever the value from either inputRx
update. This method is faster than combiningRx
s usingfor { a <- ra; b <- rb } yield (a, b)
.val r1: Rx[Int] val r2: Rx[Int] val zipped: Rx[Int] = r1.zip(r2) // r1 => 0 8 9 ... // r2 => 1 4 5 6 ... // zipped => (0,1) (8,1) (8,4) (8,5) (8,6) (9,6) ...
This method, together with
Rx.apply
, forms amApplicative
.mapN
syntax is available via themonadic-rx-cats
package.