Skip to content

Instantly share code, notes, and snippets.

@omahlama
Created February 9, 2015 07:18
Show Gist options
  • Save omahlama/ff5a879ca209b3b1d287 to your computer and use it in GitHub Desktop.
Save omahlama/ff5a879ca209b3b1d287 to your computer and use it in GitHub Desktop.
Mixin for react components that have a Bacon.model named "model" as a property
var BaconModelMixin = {
componentDidMount: function() {
this.unsubscribe = this.props.model.onValue(this.setState.bind(this));
},
componentWillUnmount: function() {
if(this.unsubscribe) {
this.unsubscribe();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment