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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Steven Chan
May 10, 2017
Programming
490
1
Share
Offline first collaboration with event sourcing
Demo code at
https://github.com/stevenchan/event-sourcing-todo-example
Steven Chan
May 10, 2017
More Decks by Steven Chan
See All by Steven Chan
Shape Recognition
stevenchan
0
45
Other Decks in Programming
See All in Programming
煩雑なSkills管理をSoC(関心の分離)により解決する――関心を分離し、プロンプトを部品として育てるためのOSSを作った話 / Solving Complex Skills Management Through SoC (Separation of Concerns)
nrslib
4
940
Kubernetes上でAgentを動かすための最新動向と押さえるべき概念まとめ
sotamaki0421
3
500
10年分の技術的負債、完済へ ― Claude Code主導のAI駆動開発でスポーツブルを丸ごとリプレイスした話
takuya_houshima
0
2.5k
JAWS-UG横浜 #100 祝・第100回スペシャルAWS は VPC レスの時代へ
maroon1st
0
140
Radical Imagining - LIFT 2025-2027 Policy Agenda
lift1998
0
340
SkillがSkillを生む:QA観点出しを自動化した
sontixyou
6
3.4k
実践ハーネスエンジニアリング #MOSHTech
kajitack
7
6.5k
Oxlintとeslint-plugin-react-hooks 明日から始められそう?
t6adev
0
270
セグメントとターゲットを意識するプロポーザルの書き方 〜採択の鍵は、誰に刺すかを見極めるマーケティング戦略にある〜
m3m0r7
PRO
0
540
クラウドネイティブなエンジニアに向ける Raycastの魅力と実際の活用事例
nealle
2
190
Vibe NLP for Applied NLP
inesmontani
PRO
0
430
10 Tips of AWS ~Gen AI on AWS~
licux
5
400
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
180
How to train your dragon (web standard)
notwaldorf
97
6.6k
Site-Speed That Sticks
csswizardry
13
1.2k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
420
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.4k
Building AI with AI
inesmontani
PRO
1
900
Why Our Code Smells
bkeepers
PRO
340
58k
So, you think you're a good person
axbom
PRO
2
2k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
370
We Are The Robots
honzajavorek
0
210
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
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