We decide to resurrect Var's apply/update methods and add new FSM class with withMod behavior. So we will have two stateful sources. FSM will not have special behavior for stateful bindings that Var.withMod currently has.
// Dirty, imperative `Var`
val c = Channel[Int]()
val x = Var(0)
c foreach { c =>
if (x() == 0) x() = c
}
c.pull(10)
c.pull(20)
assert(x() == 10)
// Pure, functional FSM
val c = Channel[Int]()
val x = FSM(0) {
case 0 => c
case _ => Dummy
}
c.pull(10)
c.pull(20)
x once { x =>
assert(x == 10)
}
We decide to resurrect Var's
apply/update
methods and add new FSM class withwithMod
behavior. So we will have two stateful sources.FSM
will not have special behavior for stateful bindings thatVar.withMod
currently has.