Created
January 26, 2015 01:39
-
-
Save roman01la/8ba85ce6f5eec57964a7 to your computer and use it in GitHub Desktop.
Reactive React components using Most
This file contains hidden or 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
import React from 'react'; | |
import most from 'most'; | |
let push = ({source: {sink}}, event) => { | |
try { | |
sink.event(event.type, event); | |
} catch (err) { | |
sink.error(event.type, err); | |
} | |
}; | |
let Button = React.createClass({ | |
_onClick: push.bind(null, (() => { | |
let clicks = most.create(() => {}); | |
clicks.forEach(console.log.bind(console)); | |
return stream; | |
})()), | |
render() { | |
return <button onClick={this._onClick}>Click Me!</button>; | |
} | |
}); | |
React.render(<Button />, document.body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment