The talk covers the following topics:
1. Introduction to event sourcing.
2. How event sourcing and Redux are similar.
3. How to implement offline mode for React Native application.
4. How everything from above was run in a production.
The talk covers the following topics:
1. Introduction to event sourcing.
2. How event sourcing and Redux are similar.
3. How to implement offline mode for React Native application.
4. How everything from above was run in a production.
"Offline mode for a mobile application, redux on server and a little bit about event sourcing." talk at React Native Camp by Viktor Turskyi
1.
Offline mode for a mobile application
Redux on server and a little bit about event sourcing
Viktor Turskyi
React Native CAMP Conference 2018
2.
About me
● CTO at WebbyLab
● Open Source developer
(Perl, JavaScript)
● 13 years in Software
development
● Successfully delivered more
than 60 projects
14.
Why to use event sourcing?
● Build specific materialized views for different business domains
● Capture intent of the data, track user behaviour (not only results)
● Audit trail
● Possibility to rollback to any previous state
● Minimize data conflicts
● High processing performance (gracefully degrade on load, no locks)
● Flexibility to change format of materialized view (replay events)
15.
Business task - create LMS for compliance
● Create training app (training == quiz): iOS, Android, Web
● Offline mode for mobile (read and write)
● Audit trail support
● Detailed analytics in mobile, web, nodejs
● Constantly evolving requirements to analytics
18.
Session (user) metrics
● Training adoption burndown chart
● Adoption level
● Predict time to finish
● Spent time in training
● Monthly activity charts
● Spent time on each question
19.
Training (group) metrics
● Training adoption burndown chart
● Aggregated students activity
● Adoption level for group
● etc
23.
Merge Redux with event sourcing
● Client: create temporary queue
● Client: Add timestamp to every event
● Server: split event handlers into two parts:
○ Pure functions with business logic (reducer)
○ Side effects containing utils (db utils etc)
● Server: Use immutable structures for metrics.
● Client and Server share the same reducers
33.
Main issues to solve
Mobile: Store larger number of events in offline mode
Backend: Store events in a more suitable place (Kafka)
Backend: Split the event queue into “realtime” and “delayed”
34.
Links
Event Sourcing pattern by Microsoft
https://docs.microsoft.com/en-us/azure/architecture/patterns/event-sourcing
Event Sourcing pattern by Martin Fowler
https://martinfowler.com/eaaDev/EventSourcing.html
"Turning the database inside out with Apache Samza" by Martin Kleppmann
https://www.youtube.com/watch?v=fU9hR3kiOK0
35.
Viktor Turskyi (koorchik)
viktor@webbylab.com
https://twitter.com/koorchik https://twitter.com/webbylab
https://github.com/koorchik https://github.com/webbylab
http://webbylab.com