Skip to content

Instantly share code, notes, and snippets.

@TheLudd
Created December 16, 2014 10:26
Show Gist options
  • Save TheLudd/24e65c08fbb15b3996ef to your computer and use it in GitHub Desktop.
Save TheLudd/24e65c08fbb15b3996ef to your computer and use it in GitHub Desktop.
module.exports = function(events, R) {
return {
listeners: {},
addListener: function(key, fn) {
events.on(key, fn);
this.listeners[key] = fn;
},
componentWillUnmount: function() {
R.forEach(function(key) {
events.off(key, this.listeners[key]);
}.bind(this), R.keys(this.listeners));
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment