dispatchr icon indicating copy to clipboard operation
dispatchr copied to clipboard

Investigate replay-based rehydration

Open mridgway opened this issue 10 years ago • 8 comments

Theoretically, stores could be reset to their original state by recording the actions and payloads that were dispatched on the server, serializing them, and then replaying them on the client to rehydrate the application. An investigation on the performance and implementation benefits for each should be done.

This could reduce the amount of code in each store since they would no longer need to implement dehydrate/rehydrate functions.

mridgway avatar Aug 23 '14 03:08 mridgway

I think is not the way to go since you retrieve a snapshot from the server. A Get req gives you a snapshot image.

And rebuild state then should be done with closer to the snapshot than try to run through a chain of effects IMHO. It will be very hard in the local what is event handler vs what shall execute business logic ect.

Plus as you said the overhead will be big for the sake of none. When the ui has rendered all the event handling should be up as soon as possible.

ptomasroos avatar Oct 11 '14 10:10 ptomasroos

Rehydrtaion of stores through replay will bring it much closer to event sourcing ideas. We are currently experimenting with replay and it works well. There are only a handful of events being replayed so performence has not been an issue. It would definitely be great to see support for that directly in the library.

stanshillis avatar Feb 17 '15 21:02 stanshillis

Yeah, I think it depends on the application, so it could be a configuration option. The implementation should be fairly simple. I'm totally willing to add this in if someone wants to do a PR.

mridgway avatar Feb 17 '15 22:02 mridgway

If the dehydrate / rehydrate methods won't go away what's the purpose ?

The goal was to reduce code right so in that case I would say there should be a single way to do the state mgmt on client side init.

But hey I'm a purist and like simplicity.

On 17 Feb 2015, at 23:06, Michael Ridgway [email protected] wrote:

Yeah, I think it depends on the application, so it could be a configuration option. The implementation should be fairly simple. I'm totally willing to add this in if someone wants to do a PR.

— Reply to this email directly or view it on GitHub.

ptomasroos avatar Feb 17 '15 22:02 ptomasroos

The need for each store to define dehydrate/rehydrate would go away. With replay, it would just re-dispatch the events on the client.

mridgway avatar Feb 17 '15 23:02 mridgway

Right, It felt like you wanted both. I could def see the benefit by having a self solving rehydration.

ptomasroos avatar Feb 18 '15 06:02 ptomasroos

Could we add an standard dehydrate / rehydrate to the BaseStore? Those methods could just set/get this.state which is what is done in most cases.

3den avatar Feb 26 '15 19:02 3den

Elegant idea. Either that or a mixin would work.

ptomasroos avatar Feb 26 '15 22:02 ptomasroos