Using with React
See original GitHub issueI’m looking for a way of using Most with React, in particular to handle DOM events via React assignment style. Similar solution is presented with RxJS.
My implementation using Most:
function handlerToStream (stream, event) {
try {
stream.source.sink.event(performance.now(), event)
} catch (err) {
stream.source.sink.error(performance.now(), err);
}
}
let Button = React.createClass({
_onClick: handlerToStream.bind(null, (() => {
let stream = most.create(() => {});
stream.forEach(event => console.log(event.target));
return stream;
})()),
render() {
return <button onClick={this._onClick}>click</button>
}
});
Is there a cleaner way to make this work?
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Tutorial: Intro to React
React is a declarative, efficient, and flexible JavaScript library for building user interfaces. It lets you compose complex UIs from small and isolated...
Read more >Getting Started - React
React is a JavaScript library for building user interfaces. Learn what React is all about on our homepage or in the tutorial. Try...
Read more >React – A JavaScript library for building user interfaces
React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and...
Read more >Hello World - React
In this guide, we will examine the building blocks of React apps: elements and components. Once you master them, you can create complex...
Read more >Add React to a Website
Add React in One Minute · Step 1: Add a DOM Container to the HTML · Step 2: Add the Script Tags ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There’s recompose library with configurable utilities compatible with most/rxjs/xstream/flyd/kefir/bacon https://github.com/acdlite/recompose/blob/master/docs/API.md
Hey @nissoh, thanks very much for the kind words! I agree: reactive programming is a great way to model highly interactive front-ends. Switching from maintaining shared mutable state, to reactive values where state updates flow through the system is definitely a different way of thinking, but has lots of advantages.
I love the simple programming model you get when using most.js + reactive-dom. There’s practically no shared state to worry about.
I’ve been meaning to update that TodoMVC and submit it, but I haven’t had time lately. When you say “fully functional”, do you mean the inline todo editing (I didn’t implement that yet)? Or did you mean something more?