Skip to content

Instantly share code, notes, and snippets.

@tkurki
Last active August 29, 2015 14:14
Show Gist options
  • Save tkurki/18636ed16f8845ec9b53 to your computer and use it in GitHub Desktop.
Save tkurki/18636ed16f8845ec9b53 to your computer and use it in GitHub Desktop.
Bacon + React
var BaconValue = React.createClass({
getInitialState: function() {
return {value: '-'};
},
render: function() {
return (
<div>{this.state.value}</div>
)
},
componentDidMount: function() {
this.unsubscribe = this.props.value.onValue(function(value) {
this.setState({
value: value
});
}.bind(this));
},
componentWillUnmount: function() {
this.unsubscribe();
}
});
var pekonia = Bacon.repeatedly(1000, [1,2,3,4]);
var App = React.createClass({
render: function() {
return (
<BaconValue value={pekonia}></BaconValue>
)
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment