UI dependency graph cleanup

This commit is contained in:
kayone 2013-10-08 18:43:41 -07:00
parent 86ea33b638
commit 4948d0608b
87 changed files with 1119 additions and 735 deletions

View file

@ -1,12 +1,16 @@
'use strict';
define(
[
'app',
'vent',
'Commands/CommandModel',
'Commands/CommandCollection',
'Commands/CommandMessengerCollectionView',
'underscore',
'jQuery/jquery.spin'
], function (App, CommandModel, CommandCollection, _) {
], function (vent, CommandModel, CommandCollection, CommandMessengerCollectionView, _) {
CommandMessengerCollectionView.render();
var singleton = function () {
@ -33,11 +37,18 @@ define(
this._bindToCommandModel.call(this, existingCommand, options);
}
CommandCollection.bind('add sync', function (model) {
CommandCollection.bind('add', function (model) {
if (model.isSameCommand(options.command)) {
self._bindToCommandModel.call(self, model, options);
}
});
CommandCollection.bind('add sync', function () {
var command = CommandCollection.findCommand(options.command);
if (command) {
self._bindToCommandModel.call(self, command, options);
}
});
},
_bindToCommandModel: function bindToCommand(model, options) {
@ -52,7 +63,7 @@ define(
options.element.stopSpin();
if (model.isComplete()) {
App.vent.trigger(App.Events.CommandComplete, { command: model, model: options.model });
vent.trigger(vent.Events.CommandComplete, { command: model, model: options.model });
}
}
});