Last active
August 29, 2015 14:14
-
-
Save tkurki/18636ed16f8845ec9b53 to your computer and use it in GitHub Desktop.
Bacon + React
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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