on - PronabM/State.js GitHub Wiki

on

Objective

This function takes a single property and handler which is called when any of the properties are changed. When a single property is changed the handler is called with two parameter, what was the old value of the state property and what is the new value. If a handler is registered on change of a property which has another state property as value, then the handler gets called whenever any state property connected to it gets changed.

Current Status

on:function(propt,handle)
{
	var obj = this;
	this.eventList[propt]=handle;
	var f = function(){
	    obj.off(propt);
	}
	return f;
},
off:function(propt)
{
	this.eventList[propt]=false;
}

I have skipped the subsequent steps due to inevitable reasons such as my final year examinations.