grrowl / redux-scuttlebutt

Distributed replicated redux store
170 stars 14 forks source link

Synchronization on the state diff level #10

Open xaviervia opened 7 years ago

xaviervia commented 7 years ago

Hi,

Thanks for publishing this.

I’m very interested in the topic of peer-to-peer store synchronization and I was planning on building a library for that on top of hyperlog or more naively on top of webrtc-signalhub (that is, without the log reconciliation). I found this project very interesting.

I was thinking however that synchronizing the store is something that can be done on state update rather than on action dispatch. I am not sure about this and I'm still trying to find out reasons for one approach or the other, so take my rationale with a grain of salt, I would like to know what you think about it:

An underlying assumption of these point is that store sync makes the application and the state become entities with separated lifecycles. The app might change while the state lives on, and the state might change while the app lives on in an older version.

As a way of a metaphor, synchronizing the state is closer to doing git. Synchronizing the action log is more like synchonizing the log of the keystrokes that the programmer made.

On the other hand the action log will probably be slimmer and easier to debug. Each might be a separate use case worth of different libraries.

grrowl commented 7 years ago

Thanks for checking it out and the feedback!

Synchronising the actions themselves has a number of benefits, including

and, crucially,

I agree that the two approaches serve different use cases. State-based syncing is simpler and easier to reckon about, but hopefully bringing scuttlebutt's strengths (distributed, resilient logs) to Redux's natural structure (time-travel, statelessness and integration with React) we'll be able to raise the bar for real-time client apps.