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
Steven Chan
May 10, 2017
Programming
500
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
47
Other Decks in Programming
See All in Programming
AWS Transform Customによる Spring Boot 2.xから4.xへのVerUp
satoshi256kbyte
2
110
楽しそうなつよつよエンジニアと目が死んでる僕/A brilliant engineer having a blast, and dead-eyed me.
3l4l5
2
260
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
460
初めての模倣学習とVLA
natsutan
0
300
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
190
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
350
Hono + Inertia + React で LP を構築した話
oukayuka
2
180
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
0
220
ALB ログから Trace を気合で繋げる技術
fohte
7
740
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
180
AIに既存システムを理解させる技術 ~レガシーを見捨てないハーネスエンジニアリング入門~
ochtum
0
160
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
360
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.5k
Design in an AI World
tapps
1
290
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
500
Site-Speed That Sticks
csswizardry
13
1.5k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
A Soul's Torment
seathinner
6
3.5k
From π to Pie charts
rasagy
0
330
For a Future-Friendly Web
brad_frost
183
10k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
750
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
290
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
550
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