Skip to content

Instantly share code, notes, and snippets.

@jcreamer898
Created August 26, 2015 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcreamer898/3912596dd0333cdf03d5 to your computer and use it in GitHub Desktop.
Save jcreamer898/3912596dd0333cdf03d5 to your computer and use it in GitHub Desktop.
// event bus as dispatcher
// actions.js
module.exports = {
addItem: (item) => {
Bus.trigger("item.added", {
item: item
});
},
removeItem: (item) => {
Bus.trigger("item.removed", {
item: item
});
}
};
// item_store.js
class ItemStore {
constructor() {
this.bindActions({
"item.added": "itemAdded",
"item.removed": "itemRemoved"
});
}
itemAdded(data) {
this.items.push(data.item);
}
itemRemoved(data) {
/* ... */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment