Expand description
This is a library for enabling cross-device local-first event syncing. It was created for Yap.Town, so it doesn’t include much that was not needed for that project.
Syncing strategy:
- Each of the user’s devices gets a unique ID.
- As users use your app, instead of the app modifying the state directly, they generate “events”. Events are associated with the device generated them, as well as a timestamp and an index within the device’s events.
- Starting from a default initial state, these events are “applied” in chronological order to get the current state.
- When syncing:
- The user’s device asks the server how many events the server has, then sends any events that it has that the server doesn’t.
- The user’s device tells the server what events it has, then the server responds with the events that the user’s device doesn’t have.
Sounds simple, but there are a few tricky parts that this library handles.
Modules§
Traits§
- AppState
- Extension trait that provides apply_event for backward compatibility
- Partial
AppState - Core trait for partial event processing without derived state computation