4 ms·
Om looks very interesting and seems to handle exactly what I've been looking for. We have reactive widgets, which is great for making changes in the data automa
by asolove 13y ago
Om looks very interesting and seems to handle exactly what I've been looking for. We have reactive widgets, which is great for making changes in the data automatically update the UI. But the hard part is closing the loop: how does the widget communicate back to the data about changes? It would be interesting if we had a zipper-like abstraction, so that the widget gets handed both its data and a function to call when it wants to change just its data. Then that function is smart enough to go find the right place in the big data structure to go do the replace.
Edit: Ok, I now see how the Om todo example is handling update, and it's really cool. It creates a set of channels that encapsulate the knowledge of how to handle each type of change to a todo [0]. That gets passed in to the todo widget as "chans" and the widget sends messages to it in its event handlers [1]. I wonder if this whole channel CRUD abstraction is general enough to make it part of Om or another layer so that it didn't have to be recreated each time.
[0] https://github.com/swannodette/todomvc/blob/gh-pages/labs/architecture-examples/om/src/todomvc/app.cljs#L106 https://github.com/swannodette/todomvc/blob/gh-pages/labs/ar...
[1] https://github.com/swannodette/todomvc/blob/om/labs/architecture-examples/om/src/todomvc/item.cljs#L40 https://github.com/swannodette/todomvc/blob/om/labs/architec...
- dustingetz 13y ago> so that the widget gets handed both its data and a function to call when it wants to change just its data this is precisely how React works.
- asolove 13y agoYeah, took me a second to wrap my head around the Om todo code. I've updated my comment with links to show how it works.
- malandrew 13y agoFor zippers, check out this library: https://github.com/dyoo/js-tree-cursor https://github.com/dyoo/js-tree-cursor