steelsojka / aurelia-redux-plugin

A Redux plugin for the Aurelia framework
MIT License
17 stars 4 forks source link

Redux DevTools doesn't update view #11

Open jmezach opened 7 years ago

jmezach commented 7 years ago

I've been trying out aurelia-redux-plugin but I noticed that setting up the Redux DevTools doesn't work with this plugin. For example, time traveling doesn't update the view.

I spent some time debugging this and I think I know why it doesn't update. In the Store there is a changeId property which is an ever increasing number that is updated every time dispatch is called on the Store instance. This works fine when we're dispatching events within our application, but when we use the Redux DevTools updates are performed on the underlying Redux Store directly which doesn't update the changeId property, thus the bindings aren't re-evaluated.

I did a bit of a dirty hack by increasing the changeId inside the ReduxPropertyObserver class when an update comes in (which is fired even when manipulating the store with Redux DevTools), and sure enough the view updates as I expect.

Obviously this isn't a good solution, since this means that the changeId could be update multiple times for a single dispatch. I guess we need some kind of hook that tells us when Redux DevTools is manipulating the store so we can increase changeId accordingly.