Skip to content

Instantly share code, notes, and snippets.

@bbarker
Created March 3, 2016 18:16
Show Gist options
  • Save bbarker/dd02976cfebe1fb9d001 to your computer and use it in GitHub Desktop.
Save bbarker/dd02976cfebe1fb9d001 to your computer and use it in GitHub Desktop.
import pl.metastack.metarx.Dict
val myDict: Dict[Int, String] = Dict()
myDict.changes.attach {
case d: Dict.Delta.Insert[Int, String] =>
println(f"Insert:: ${d.key}%d : ${d.value}%s")
case d: Dict.Delta.Update[Int, String] =>
println(f"Update:: ${d.key}%d : ${d.value}%s")
case _ => ()
}
println("test out")
myDict(1) = "one"
myDict(2) = "two"
myDict(1) = "one"
myDict(1) = "not one"
myDict.update(1, "one")
myDict(3) = "three"
var three = myDict(3)
three = "not three"
// no update, but not unexpected really; how could myDict know?
myDict(3) = three
//updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment