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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Steven Chan
May 10, 2017
Programming
1
480
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
44
Other Decks in Programming
See All in Programming
CSC307 Lecture 09
javiergs
PRO
1
840
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
470
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
200
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
130
Basic Architectures
denyspoltorak
0
680
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
460
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
2.6k
CSC307 Lecture 03
javiergs
PRO
1
490
MUSUBIXとは
nahisaho
0
140
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
180
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
590
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
290
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
234
18k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Raft: Consensus for Rubyists
vanstee
141
7.3k
The Cost Of JavaScript in 2023
addyosmani
55
9.5k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
330
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.4k
Statistics for Hackers
jakevdp
799
230k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
66
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
290
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