3 ms·
This looks really fun way to develop React apps. I just developed a React app, and managed to trip over state related problems at every stage. First with full
by jarpineh 11y ago
This looks really fun way to develop React apps.
I just developed a React app, and managed to trip over state related problems at every stage. First with full state outside components, then within a top component, then I tried with a simple store type concept. Whenever I had to deal with async issues, I made a mistake with communicating ongoing state or getting React to notice changed state. I was waiting for Redux to go 1.0 (which it apparently did yesterday!).
I wonder how async updates, like network requests, to the model should work? Perhaps two channels, one for events from the components to what ever is handling requests for you (I just used D3, since I have some other uses for it), and then it can message the results via channel to what actually updates the model.
OP's example reminded me strongly of Mithril [1]. Though with addition of CSP channels to communicate changes, and explicit external render call, which Mithril allows also, but I don't remember having to use. It's clean and simple looking, and I like it. Now I got one more way to mess with my app state. And should I decide to use Mithril again on other projects, CSP seems like a worthy addition if it can be applied this easy.
[1] https://lhorie.github.io/mithril/ https://lhorie.github.io/mithril/
- davexunit 11y agoI have a small project that I poke at that uses Mithril + Kefir for a nice virtual DOM + FRP architecture. A few lines of glue code and I was good to go: https://git.dthompson.us/guix-web.git/blob/HEAD:/js/utils.js#l48 https://git.dthompson.us/guix-web.git/blob/HEAD:/js/utils.js... (pardon the self-signed cert)
- jarpineh 11y agoKefir looks interesting, thanks for the pointer! Now if somebody makes async channel combinator so that I wouldn't had to build so much boilerplate for network requests. Be it direct callbacks or promises or the new fetch specification, control flow of async operations seems to require more than one channel and glue code in between. That seems to bend the paradigm a bit too much for what is essentially IO ops in my apps.