Open xaviervia opened 7 years ago
Thanks for checking it out and the feedback!
Synchronising the actions themselves has a number of benefits, including
user.isFriend
is possible, next to user.name
and user.avatar
.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.
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:
While actions are the specific way that Redux manages store updates, every application built with a single central state architecture will have an object structure. If the synchronization targets the state instead of the action log, it could be a generic solution.
Similarly, application updates that are rolled out first on one client and only afterward on others will work gracefully with state-level sync, but will break for action-level sync. Say a new action is introduced: the old clients will not know what to do with it. If the update log contains only say, jsonpatch diffs, the older clients will be able to have their state sync without conflict until they receive the new app version.
In many real life applications, some actions and some parts of the state will have to be ignored by the synchronization. In my mind is more straightforward to specify this by setting a namespace of the state to be synchronized (for example,
state.shared
) rather than a blacklist or whitelist of action types.The tools for diffing JSON are already there, so it would be simple to have a generic interface for state synchronization in which every JSON diff is a "commit", even tagged with a hash and author if so required.
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.