2 ms·
The first call to dispatch should probably have been (dispatch [:deleted-todo todo-id]) Though personally, I would prefer to define dispatch as (defn
by dkersten 12y ago
The first call to dispatch should probably have been
(dispatch [:deleted-todo todo-id])
Though personally, I would prefer to define dispatch as
(defn dispatch [tag & args]
(put! dispatch-chan (apply vector tag args)))
instead and then change the second call to
(dispatch :txs tx-data root-cursor)
(Also as a style thing, I'd call it dispatch! since it has side effects)
Good article though and describes something very similar to what I'm doing in my own Om project. I've abstracted the dispatching into om-tools mixins though, so you can do something like this:
(dom/div
{:on-click (.sender owner :click-event)}
"Click Me")
And when the div is clicked, :click-event is dispatched (I also have the concept of component ids and if the component has an id, it is included in the event, so you can register for all events with a given tag, all events from a given component, or only events from a given component with a given tag).
So far, its working quite well.
EDIT: fixed typo in the code
- benaiah 12y agoOff-topic, but when did HN get code fragments? That's a really cool development.