Skip to content

Resolver Manipulation and Events

Henrik Vendelbo edited this page Jan 16, 2014 · 6 revisions

Entries in a resolver can be change in several ways. The easiest is changing a specified point using set.

var r = Resolver({});
r.set("a.b.c","new value");

This will replace the existing value with the one you specify. If you only want to set it if it hasn't previously been set call declare. For boolean values you can also use toggle to invert the current value.

When a value changes, the previously registered change listeners will be called. The change listener signature is:

 function onchange(ev) {
 }

To add a change listener,

r.on("change","a.b.c",function(ev) {
  ev.base == r("a.b")
  ev.symbol == "b"
  ev.value == new value
  ev.oldValue == old value
  ev.binding == undefined
});

If you want the callback to be called immediately after binding add the "bind" type.

r.on("change bind","a.b.c",function(ev) {
  ev.value == new value
  binding == true/false. When binding it will be true
});

Clone this wiki locally