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
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
6
1.2k
inferと仲良くなる10分間
ryokatsuse
1
290
GitHub Copilot CLIのいいところ
htkym
2
1.2k
誰も頼んでない機能を出荷した話
zekutax
0
150
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
310
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
110
Zod v4 Codec でスキーマに型変換を埋め込む REST API 設計 #TSKaigi2026
ryutaro_yako
0
180
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
2
400
開発体験を左右するライブラリの API 設計 - GraphQL スキーマ構築ライブラリから考える #tskaigi
izumin5210
2
1.4k
tsserverとは何だったのか、これからどうなるのか
nowaki28
1
430
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
180
3Dシーンの圧縮
fadis
1
550
Featured
See All Featured
Designing for humans not robots
tammielis
254
26k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
120
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
520
The Curious Case for Waylosing
cassininazir
1
370
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
55k
Discover your Explorer Soul
emna__ayadi
2
1.1k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
200
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.7k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Claude Code のすすめ
schroneko
67
220k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.8k
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