Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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