Comments (1)
Thanks for checking it out and the feedback!
Synchronising the actions themselves has a number of benefits, including
- Unrecognized actions are still compatible with outdated reducers, they simply won't have an effect on state ā the application View/Renderables can't become out of sync with the state shape, since the application is responsible for them both. Local state might be different to remote state, but the app will render truthfully. We can also update the app and simply replay all known actions to update.
- Clients can always emit actions, and can always replay actions emitted by other clients, even if they happened before local client's actions. There's no way to conflict, like what might happen if two clients overwrite a common value or key in the shared store.
- With synced actions logs, shared and local actions can mutate local and shared states. Compared to store sync: Shared state changes would only be caused by shared actions, local state changes would only be caused by local actions.
- This means you don't have to split into a local "UI" reducer and shared "posts" reducer, but can decide within a reducer which keys a public or private action affects. A relative value
user.isFriend
is possible, next touser.name
anduser.avatar
. - Further, with redux-scuttlebutt your locally emitted actions will maintain their "correct" position in time relative to when shared actions occurred, whereas with synced stores they mustn't ever touch.
- This means you don't have to split into a local "UI" reducer and shared "posts" reducer, but can decide within a reducer which keys a public or private action affects. A relative value
and, crucially,
- Syncing actions means your clients can be offline for seconds, or minutes, or days, and they'll still sync. Diffing store changes opens the door to conflicts, or situations where we're not sure "who came first" or "who won" when working on the same piece of data.
- Syncing actions leaves the decision of dealing with these conflicts up to the reducer, and therefore the application itself, so you can resolve conflicts any way which is appropriate.
- Also (and this is the most bizarre to explain) when multiple distributed clients are connected, your local client can exist without the latest actions from one or many remote clients having been applied. When they are eventually applied, it's as if they already happened in the past. We only have to write the one set of logic (as we do with renderable components for the views) which gives us flexibility and predictability.
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.
from redux-scuttlebutt.
Related Issues (14)
- [Discussion] Why syncing actions instead of data model? HOT 6
- Action log compaction
- Scopes (sharding/subscriptions) HOT 1
- Chat demo errors HOT 2
- Don't gossip actions which don't change state
- Usage with create-react-app
- Using with existing socket connection? HOT 1
- Missing action.timestamps HOT 6
- Improve/switch underlying protocol implementation HOT 6
- using with connect() HOT 5
- Some actions aren't replayed or replayed out of order (visible in examples/counter) HOT 1
- Action signature hashes (anti-tampering) HOT 3
- Replay scuttlebutt updates from orderedHistory HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redux-scuttlebutt.