Yes, warp9 supports it. To do atomically change to several variable you should put those changes into
lambda and pass the lambda to warp9.tx
, it returns a function that do the specified
atomic updates when it is invoked.
JS
var alice = new warp9.Cell(10);
var bob = new warp9.Cell(15);
var history = new warp9.List();
var snapshot = warp9.do(function(){
return JSON.stringify({
Alice: alice.get() + "$",
Bob: bob.get() + "$",
sum: (alice.get() + bob.get()) + "$"
});
});
snapshot.onChange(function(snapshot){
history.add(snapshot.get());
});
var parcel = new warp9.Cell("2");
warp9.render(placeholder, ["div",
["div",
["div", {"class": "accounts-title"},
["div", ["b", "Alice's account"]],
["div", ["b", "Bob's account"]]],
["div", {"class": "accounts-value"},
["div", ["span", alice, "$"]],
["div", ["span", bob, "$"]]],
["div", {"class": "clear"}]],
["div", {"class": "transfer"},
["input-text", parcel],
["button", {"!click": warp9.tx(function(){
alice.set(alice.get()-parseInt(parcel.get()));
bob.set(bob.get()+parseInt(parcel.get()));
})}, "Transfer from Alice to Bob"]],
["div", {"class": "history"},
["div", ["b", "Account history"]],
["div", {"class": "snapshots"}, history.lift(function(item){
return ["div", item];
})]]
]);