on
Listen to when a compute changes value.
compute.on(eventType, handler)
const age = compute( 33 );
age.on( "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.