Om and Flux
justin.harmonize.fm
justin.harmonize.fm
This post in particular seems to be advocating the concept of having a single 'aggregate root' as opposed to independently loaded 'entities', and Flux sounds like it just advocates the use of an 'event bus' to send separate 'read'/'write' 'commands' to 'domain objects'... the main difference of course being that all this recently has been specifically with the browser in mind. Is that a reasonable assessment?
Amongst people that I associate with that build complex web apps, there's been an ongoing debate on whether a centralized event dispatch (what Flux advocates) is preferable to decentralized event emitting components (what Backbone and web components advocate).
For most of my career, I've been a fan of decentralized event emitting components. However, with Om's persistent data structures and functional render loop, having all of your data in a single place is suddenly a lot more palatable. From there, I think the event bus approach flows naturally.
Or at least, that's what I'm thinking now :) I still haven't written something with complex enough tests and other external dependencies to have gotten bit by this yet.
In CQRS/ES you don't usually want to store the state as such, you just store all the logical events which lead to a certain state. While the Datomic approach is certainly valuable for certain scenarios if you want to query historical data, it's less so if you want to know why something looks the way it currently does (in terms of the domain).
(At least that's my understanding of Datomic, I may be mistaken.)
I even suspect if Peter Hunt mentioned how they are doing DDD+CQRS for building applications, it might have been met with ridicule from audience.
It is kind of interesting, the field of software engineering is not that old, but there already probably multiple cycles of the same concept being rediscovered over and over again.
Another rather cliche one is callback based concurrency. There was a wave of "oh look at this new thing we discovered, you don't block and instead provide a function to be called later". And many older folks probably looked at each other and said "Wait, what year is it?"
[0]: http://elm-lang.org
[1]: https://github.com/seliopou/elm-d3
[2]: http://computationallyendowed.com/blog/2014/07/20/reactive-m...
(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
I'm using CSP in my project with this project: https://github.com/ubolonton/js-csp, and I've been studying flux this week. Yesterday and today I've been writing a channel-based dispatcher, and digesting how to convert the flux concepts into a channel-based system.
Thanks for this post! I'm somewhat new to CSP so this sheds a whole lot of light on how to do it. I knew there must be a better way to do the dependencies, because right now I'm manually managing them. Using `merge` is brilliant.
Just tweeted this on Sunday: https://twitter.com/jlongster/status/496019503730679809 :)
The same author created a LightTable tutorial to introduce ClojureScript that's also pretty great: https://github.com/swannodette/lt-cljs-tutorial
I don't use LightTable regularly, but I did for these walkthroughs. I would recommend doing the same unless you have a good Vim or Emacs environment already setup.