Implemented indicators

This commit is contained in:
Borys Levytskyi
2015-04-04 17:00:06 +03:00
parent 960b61de03
commit fab8668993
8 changed files with 82 additions and 36 deletions

View File

@@ -1,4 +1,6 @@
(function(core){
var is = core.is;
function ObservableObject () {
this.executionHandlers = [];
}
@@ -33,9 +35,25 @@
}
};
ObservableObject.prototype.observe = function (handler){
ObservableObject.prototype.observe = function (property, handler){
var func;
if(is.aFunction(property)) {
func = property;
}
else if(is.string(property) && is.aFunction(handler)) {
func = function (p, v) {
if(p === property) {
handler(p, v)
}
}
}
else {
console.warn('Unsupported set of arguments: ', arguments);
return;
}
var handlers = this.executionHandlers;
var index = handlers.push(handler);
var index = handlers.push(func);
return function () { handlers.splice(1, index); }
};