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
ローカルLLMでどこまでコードが書けるか / How much code can be written on a local LLM
kishida
2
340
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
670
サプライチェーン攻撃対策「層を重ねて落ちない壁」を10日間で組み上げた話 #TechLeadConf2026
kashewnuts
1
240
AgentCore Optimizationを始めよう!
licux
3
230
属人化しないコード品質の作り方_2026.04.07.pdf
muraaano
0
330
エラー処理の温故知新 / history of error handling technic
ryotanakaya
7
1.9k
過去のレビュー知見をSkillsで資産化した話
pkshadeck
PRO
1
1.7k
20260514 - build with ai 2026 - build LINE Bot with Gemini CLI
line_developers_tw
PRO
0
390
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
770
AIを導入する前にやるべきこと
negima
2
340
[RubyKaigi 2026] Require Hooks
palkan
1
310
ハーネスエンジニアリングとは?
kinopeee
13
6.9k
Featured
See All Featured
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
440
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
Prompt Engineering for Job Search
mfonobong
0
300
Producing Creativity
orderedlist
PRO
348
40k
Chasing Engaging Ingredients in Design
codingconduct
0
190
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
Rails Girls Zürich Keynote
gr2m
96
14k
Agile that works and the tools we love
rasmusluckow
331
21k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
230
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