Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save orangewolf/0d2d4a2109525186a8c1e489b5125b14 to your computer and use it in GitHub Desktop.
Save orangewolf/0d2d4a2109525186a8c1e489b5125b14 to your computer and use it in GitHub Desktop.
}
+ this.onUpdateMessage = this.updateMessage.bind(this)
+ this.onUpdateUser = this.updateUser.bind(this)
+ this.onUpdateEvent = this.updateEvent.bind(this)
}
componentWillMount(){
- eventStore.on('current event fetched', this.updateMessage.bind(this));
- eventStore.on('votes counted', this.updateMessage.bind(this));
- userStore.on('voted set to false', this.updateUser.bind(this));
- eventStore.on('new event created', this.updateEvent.bind(this));
+ eventStore.on('current event fetched', this.onUpdateMessage);
+ eventStore.on('votes counted', this.onUpdateMessage);
+ userStore.on('voted set to false', this.onUpdateUser);
+ eventStore.on('new event created', this.onUpdateEvent);
+ }
+
+ componentWillUnmount(){
+ eventStore.removeListener('current event fetched', this.onUpdateMessage);
+ eventStore.removeListener('votes counted', this.onUpdateMessage);
+ userStore.removeListener('voted set to false', this.onUpdateUser);
+ eventStore.removeListener('new event created', this.onUpdateEvent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment