Added dependency injection to command handlers.

This commit is contained in:
Borys Levytskyi
2015-04-03 12:05:04 +03:00
parent ce2db72582
commit 51ad680236
3 changed files with 31 additions and 27 deletions

View File

@@ -39,6 +39,17 @@
cmd.subscribe(handler);
}
if (typeof handler == "object") {
if(typeof handler.execute != "function"){
console.warn('Given handler is an object, but doesn\'t have "execute" function');
return cmd;
}
this.di.resolveProperties(handler);
cmd.subscribe(handler.execute.bind(handler));
}
return cmd;
};
@@ -55,8 +66,6 @@
runObservers.forEach(function(o){ o(); });
}
window.app = app;
app.addControllerMixin = function (component) {
component.attachView = function(viewElement) {
@@ -77,5 +86,6 @@
};
}
window.app = app;
})(window.should, window.commandr, window.bindr, window.Container);