OlivierBlanvillain / monadic-html

Tiny DOM binding library for Scala.js
https://olivierblanvillain.github.io/monadic-html/examples/
MIT License
225 stars 24 forks source link

'merge' method initialization error? #103

Open sometao opened 6 years ago

sometao commented 6 years ago

example of Merge method in doc is:

   * 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 ...

but, I run code below:

  @JSExport
  def run(): Unit = {
    val a = Var(0)
    val b = Var(1)
    val c = a.merge(b)

    val body = {
      <div>
        <div>a:{a}</div>
        <div>b:{b}</div>
        <div>c:{c}</div>
      </div>
    }
    mount(dom.document.body, body)
  }

got result:

a:0
b:1
c:1

not what I expect:

a:0
b:1
c:0

Anything wrong here?