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
1
470
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
43
Other Decks in Programming
See All in Programming
Flutter with Dart MCP: All You Need - 박제창 2025 I/O Extended Busan
itsmedreamwalker
0
140
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
280
意外と簡単!?フロントエンドでパスキー認証を実現する WebAuthn
teamlab
PRO
2
690
Namespace and Its Future
tagomoris
6
700
はじめてのMaterial3 Expressive
ym223
2
170
速いWebフレームワークを作る
yusukebe
5
1.7k
Laravel Boost 超入門
fire_arlo
2
210
TDD 実践ミニトーク
contour_gara
1
290
Claude Codeで挑むOSSコントリビュート
eycjur
0
200
Putting The Genie in the Bottle - A Crash Course on running LLMs on Android
iurysza
0
130
もうちょっといいRubyプロファイラを作りたい (2025)
osyoyu
0
350
ファインディ株式会社におけるMCP活用とサービス開発
starfish719
0
250
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
330
21k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.5k
Optimizing for Happiness
mojombo
379
70k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
268
13k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
Balancing Empowerment & Direction
lara
3
610
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
520
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.7k
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