Skip to content

Instantly share code, notes, and snippets.

@MHerszak
Created November 2, 2017 14:48
Show Gist options
  • Save MHerszak/beb6fc4883d68f7e1753479becd7c23f to your computer and use it in GitHub Desktop.
Save MHerszak/beb6fc4883d68f7e1753479becd7c23f to your computer and use it in GitHub Desktop.
componentDidMount() {
const events = [{
service: 'conversation',
event: 'created',
eventFunc: this.addConversation,
},
{
service: 'conversation',
event: 'removed',
eventFunc: this.removeConversation,
}];
// this makes your events management hard to handle
const { app } = this.context;
forEach(events, ({ service, event, eventFunc }) => {
app.service(service).on(event, eventFunc);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment