mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2026-01-21 03:12:43 +01:00
Added dependency injection to command handlers.
This commit is contained in:
14
app/app.js
14
app/app.js
@@ -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);
|
||||
Reference in New Issue
Block a user