Flux Pattern
var Dispatcher = function () {
return {
_stores: [],
register: function (store) {
this._stores.push({store: store});
},
dispatch: function (action) {
if (this._stores.length > 0) {
this._stores.forEach(function (entry) {
entry.store.update(action);
});
}
}
}
};function register(store) {
if (!store || !store.update || typeof store.update !== 'function') {
throw new Error('You should provide a store that has an update method');
} else {
this._stores.push({store: store});
}
}Related links:
Last updated