So of course, I had to try it out.
I don’t have many issues when using the Flux architecture as the author does, I suspect because using dojo/topic and dbind alleviate some of those issues. Or maybe I just haven’t built a large enough app.
Either way, I’m always game to try something new and I’m a fan of RxJS anyway. So I took the sample from my Dojo-Flux demo and updated it with RxJS. This meant there was no more need for dojo/topic and unfortunately, I couldn’t really get dbind to play nicely with RxJS subscribe method, at least not in a meaningful way, so I just did away with it.
The first thing we want to do is create an Intent.
This sort of takes the place of using dojo/topic. It has it’s own Subject that can be subscribed to. In this case, an Action can pass an update to the Intent and the subject will pass the update into the flow of data.
Then I can make a dead simple action that isn’t much different from when it used dojo/topic.
Open the Store
Before the Store used dojo/Stateful to watch for updates, but now we can just use a plain object, subscribe to updates from the Intent and pass those updates via another Subject.
As you can see here, using the Subject again, we can kind of mock up the Store to pass through updates in state through the application. I’m not really adding any error checking/handling in these steps, but it would probably be prudent to handle that in the Store to prevent bad data from getting by.
Up to the View
At this point, the View only needs to know about updates to the Store, so we can subscribe to changes in the store and update the DOM as needed.
This is the portion where I was disappointed I couldn’t get dbind working correctly. There might be a way to bind to a subscription update, but I couldn’t quite figure it out.
You can find the repo for this demo here.