4 ms·
At the moment I'm sold on Mode-View-Intent, which is more delarative and non-OOP. I also have the feeling it lets me compose a bit more easy. DOMStream = v
by k__ 10y ago
At the moment I'm sold on Mode-View-Intent, which is more delarative and non-OOP. I also have the feeling it lets me compose a bit more easy.
DOMStream = view(model(intent(DOM)))
DOMStream.subscribe(render)
intent() takes the DOM, wires up some interactions and returns streams "of" these interactions
model() takes streams of interactions, wires them up with data retrieval and mutation streams and returns these data-streams
view() takes the data-streams and uses them to create DOM mutations-stream, which it returns.
The nice thing is that these observable streams are really nice to filter, map, debounce etc. Also, it helps with fast realtime data stuff, because you can easily wire up these fast streams with a tiny part of your app and the rest of it won't even notice (which is a bit ugly if you got a big state-tree that represents your whole app state).
The not so nice thing is, that controlling them completely declaratively has a steep learning curve.
- jobigoud 10y ago> model() takes streams of interactions, wires them up with data retrieval and mutation streams and returns these data-streams I think that's called a controller or presenter in other patterns. Actually your view and intent also do what a controller would do. The DOM is your actual view, and your data your actual model.
- k__ 10y agoYou're right, the names are badly choosen. In every function the same is happening, streams are created/wired up with other streams. The differentiation here seems to be, that the Model function just wires up streams for the data, the View function just wires up streams for the display and the Intent function just wires up streams for the interactions.