addEventListener
Listen to when a compute changes value.
compute.addEventListener(eventType, handler)
var age = compute(33);
age.addEventListener('change', function(ev, newVal, oldVal){
ev //-> {type: "change", batchNum: 5}
newVal //-> 34
oldVal //-> 33
});
age(34);
Parameters
- eventType
{String}
:The name of the event to bind on, usually
change
. - handler
{function(event, args...)}
:The handler to be called when this type of event fires.