Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Offline first collaboration with event sourcing
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Steven Chan
May 10, 2017
Programming
1
480
Offline first collaboration with event sourcing
Demo code at
https://github.com/stevenchan/event-sourcing-todo-example
Steven Chan
May 10, 2017
Tweet
Share
More Decks by Steven Chan
See All by Steven Chan
Shape Recognition
stevenchan
0
44
Other Decks in Programming
See All in Programming
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
170
QAフローを最適化し、品質水準を満たしながらリリースまでの期間を最短化する #RSGT2026
shibayu36
2
4.4k
Data-Centric Kaggle
isax1015
2
780
組織で育むオブザーバビリティ
ryota_hnk
0
180
AI巻き込み型コードレビューのススメ
nealle
2
390
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
300
CSC307 Lecture 09
javiergs
PRO
1
840
Fragmented Architectures
denyspoltorak
0
160
登壇資料を作る時に意識していること #登壇資料_findy
konifar
4
1.2k
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
650
高速開発のためのコード整理術
sutetotanuki
1
400
Best-Practices-for-Cortex-Analyst-and-AI-Agent
ryotaroikeda
1
110
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Become a Pro
speakerdeck
PRO
31
5.8k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
200
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
440
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
730
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
410
SEO for Brand Visibility & Recognition
aleyda
0
4.2k
Building Adaptive Systems
keathley
44
2.9k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
62
50k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.2k
Done Done
chrislema
186
16k
Transcript
Offline First Collaboration with Event Sourcing Steven Chan - @stevnchan
GoodNotes
Syncing is hard
What we have tried
Apple CloudKit • Remote database API • Need to implement
syncing with local cache ourselves • Designing a correct algorithm to sync two object graphs is hard • Limited schema migration support • Undocumented limit for sharing records
Google Firebase • Real-time database • Mobile SDKs available •
Offline mode: store updates in a queue • Performance become worse as the queue become long
Event sourcing to rescue
Event sourcing to rescue 1. Store all changes as events
in a single queue 2. Only need to sync the event queue 3. Derive the app state from the event queue 4. Migration = rewrite the derivation function
Todo app example 1. {inserted, id123, “Buy milk”} 2. {completed,
id123} 3. {deleted, id123}
Update app state 1. {inserted, id123, “Buy milk”} 2. {completed,
id123} 3. {deleted, id123}
Update app state 1. {inserted, id123, “Buy milk”} 2. {completed,
id123} 3. {deleted, id123}
Update app state 1. {inserted, id123, “Buy milk”} 2. {completed,
id123} 3. {deleted, id123}
Update app state 1. {inserted, id123, “Buy milk”} 2. {completed,
id123} 3. {deleted, id123}
Syncing • Server: maintain an event queue = the source
of truth • Clients: upload local events to server, download unseen events, and then update the app state. • That’s it!
Syncing A B C A B C D E F
Client Server F D E
Syncing A B C A B C D E F
Client Server F D E
Syncing A B C A B C D E F
Client Server F D E
Conflicts handling • Pick the latest value by update time
• Pick the value with the largest update count • Use vector clocks to detect conflicts
Demo
Q&A