SlideShare a Scribd company logo
MobX: path to
simplicity
6/28/18
Staff UI Developer
Dmitrii Turlychkin
St. Petersburg
(Russia)
Saratov
(Russia)
Kharkiv
(Ukraine)
Krakow
(Poland)
Lviv
(Ukraine)
San Ramon
(CA)
Dallas (TX)
Milwaukee (WI)
New York (NY)
Wayne (NJ)
Atlanta (GA)
St. Petersburg (FL)
Corporate office Site office
Belgrade
(Serbia)
About
Software Engineer in Grid Dynamics
UI developer
Lecturer in Yuri Gagarin SSTU
Public speaker
Try to make world better
Agenda
•  Why did we desire to select MobX?
•  MobX features overview
•  Using for real-world tasks
•  Asyncrony
•  Side effects
•  Our solution based on MobX
3/2/18
4
•  SPA (single page application)
•  Server side rendering
•  Reactions beside forms
•  A lot of forms on the same page
•  Charts
•  Grids
•  Support mobile devices from iPhone 5S
•  Good performance (Lighthouse for testing)
Business requirements
MobX: the way to simplicity
Redux
• Simple
• Small size(6 кб)
• Functional programming paradigm
• Immutability
• Hard understating curve
Redux highlights
• One store – one source of truth
• A lot of boilerplate
• Need manipulations for better
performance out of the box
• Time traveling out of the box
• Dan Abramov J
MobX: the way to simplicity
MobX
•  Simple for start
•  OOP programming paradigm
•  Mutability
•  Magic inside
•  Observable & Observer
•  Friendly for nested structures
MobX: the way to simplicity
MobX highlights
• Automatic change detection
• Implicit realization
• Global and local usage
• ”Reactivity”
• Simple for start
• State available for read and
write
• state === state (always is
actual)
• State can be normalized and
renormalized
MobX: the way to simplicity
Components out of the
box
•  @observable
•  @computed
•  @action
•  autorun
•  reaction
•  transaction
•  untracked
@observable
Structures out of the box
•  Arrays
•  Objects
•  Maps
•  Boxed values
MobX: the way to simplicity
MobX with React
•  @observer
•  @inject
@observer
MobX: the way to simplicity
Components out of the
box
•  @observable
•  @computed
•  @action
•  autorun
•  reaction
•  transaction
•  untracked
MobX: the way to simplicity
Strict mode
Components out of the
box
•  @observable
•  @computed
•  @action
•  autorun
•  reaction
•  transaction
•  untracked
Transaction
•  Transaction can be used to batch a bunch of updates without
notifying any observers until the end of the transaction. 
•  Takes a function as argument and runs it. 
•  No observers are notified until this function has completed. 
Transaction
•  Transaction  returns any value that was returned by
the worker function. 
•  Note that transaction runs completely synchronously. 
•  Transactions can be nested. 
•  Only after completing the outermost  transaction  pending
reactions will be run.
MobX: the way to simplicity
27
•  Set fields with value based on select
value from the drop-down
•  Reset errors
•  …………
Business story
MobX: the way to simplicity
MobX: the way to simplicity
Components out of the
box
•  @observable
•  @computed
•  @action
•  autorun
•  reaction
•  transaction
•  untracked
MobX: the way to simplicity
32
Business story
•  Calculate the percentage of
required valid filled fields and
display on the "progress bar" for
forms on the tab
•  …………
MobX: the way to simplicity
34
•  Calculate the percentage of
required valid filled fields and
display on the "progress bar" for
forms on the tab
•  Calculate overall the percentage for
all forms on all tabs on the page
and display it on another "progress
bar"
•  …………
Business story
MobX: the way to simplicity
MobX: the way to simplicity
MobX: the way to simplicity
this.title!
this.modalType!
this.userAction! this.email!
complexModalName!
@computed
Components out of the
box
•  @observable
•  @computed
•  @action
•  autorun
•  reaction
•  transaction
•  untracked
MobX: the way to simplicity
this.title!
this.modalType!
this.userAction! this.email!
complexModalName!
@autorun
MobX: the way to simplicity
43
•  Setting values from the form on the
first tab should be changed count
and types of fields on the last tab
•  …………
Business story
MobX: the way to simplicity
MobX: the way to simplicity
Components out of the
box
•  @observable
•  @computed
•  @action
•  autorun
•  reaction
•  transaction
•  untracked
MobX: the way to simplicity
MobX: the way to simplicity
Reaction
•  computed(expression).observe(action(sideEffect))
•  autorun(() => action(sideEffect)(expression))
Equivalent of reaction
50
•  Optimization of network resources
•  …………
Business story
MobX: the way to simplicity
Data
Service#1
Data
Service#2
Data
Service#3
Data
Service#4
Data
Service#5
Data
Service#6
Asynchrony
•  The action wrapper / decorator only affects the currently
running function, not functions that are scheduled (but not
invoked) by the current function! 
•  This means that if you have a setTimeout,
promise.then or async construction, and in that callback
some more state is changed, those callbacks should be
wrapped in action as well!
MobX: the way to simplicity
1. Add action to a promise “then” function
2. The runInAction utility
3. async / await
4. flows
Writing asynchronous actions
MobX: the way to simplicity
MobX: the way to simplicity
MobX: the way to simplicity
MobX: the way to simplicity
Own Solution
FormBuilder
Configuration File
Components for integration with
markup
External onChanged Callbacks
Configuration File
Described initial information for initialization each of controls
• Name
• Transformers (onChange
onBlur, onFocus)
• Validators (sync, async)
• Control 
• isDisabled
• isHidden
• isTouched
• Error state
FormBuilder
Map (MobX)
Flow (MobX)
@computed for validation status
@autorun
MobX State Tree
• Models
• Views 
• Actions
MobX State Tree Features
• Asynchrony
• Snapshots
• Patches
• Composing trees
Pros and cons
•  Writing the flexible solution for the project
needs
•  Experience with MobX
•  MobX gives a good performance out of the
box
•  MobX work fine with SSR
•  Computed value from computed values can
be organized simply
•  A lot of useful features for developing
•  Happy customer J
•  Time for creation “framework” for out forms
(creation of a bicycle)
•  “Magic” inside
•  Need to investigation how works some
features
Conclusion
•  MobX can be successfully used for developing SPA applications with strong requirements for
performance and huge forms.
•  Interaction beside forms and controls can be simply organized
•  Documentation, community and support are great
•  Simple start
Q&A
•  Mobx — управление состоянием вашего приложения
•  Как работает MobX изнутри и сравнение его с redux
•  https://github.com/mobxjs/mobx
•  https://github.com/mobxjs/mobx-react
•  https://github.com/mobxjs/mobx-state-tree
•  https://github.com/mobxjs/mobx-utils
•  https://github.com/mobxjs/mobx-react-devtools
Useful links
www.griddynamics.com
Thank you for your
time!
69

More Related Content

PDF
What's new in Femap 11.3 • FEA Analisten Stream
PPTX
jBPM Suite admin workshop
PDF
'Architecture of modern frontend apps' by YURIY DOBRYANSKYY at OdessaJS'2020
PPTX
Travis Wright - PS WF SMA SCSM SP
PDF
Empowering Business Users with Process Management Tools
PPTX
Rpa automation anywhere training in hyderabad
PPTX
Flux architecture
PDF
Feature Toggle: HomeToGo Use Case
What's new in Femap 11.3 • FEA Analisten Stream
jBPM Suite admin workshop
'Architecture of modern frontend apps' by YURIY DOBRYANSKYY at OdessaJS'2020
Travis Wright - PS WF SMA SCSM SP
Empowering Business Users with Process Management Tools
Rpa automation anywhere training in hyderabad
Flux architecture
Feature Toggle: HomeToGo Use Case

Similar to MobX: the way to simplicity (20)

PDF
React state management with Redux and MobX
PPTX
Develop in ludicrous mode with azure serverless
PDF
Pragmatic Monolith-First, easy to decompose, clean architecture
PPTX
Introduction to react native with redux
PPS
CS101- Introduction to Computing- Lecture 32
PPTX
JS Essence
PDF
Andrii Sliusar "Module Architecture of React-Redux Applications"
PPT
javascript Event Handling and introduction to event.ppt
PPTX
What’s expected in Spring 5
PPTX
Single Page Applications: Your Browser is the OS!
PDF
An Overview of the React Ecosystem
PPTX
IP Unit 2.pptx
PPTX
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
PPTX
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
PDF
Flopsar tesacom-technical-introduction v1a-eng
PPTX
All about that reactive ui
PPT
Event Programming JavaScript
PDF
Microservices: The Best Practices
PPTX
Spring batch
PPTX
DBmaestro's State of the Database Continuous Delivery Survey- Findings Revealed
React state management with Redux and MobX
Develop in ludicrous mode with azure serverless
Pragmatic Monolith-First, easy to decompose, clean architecture
Introduction to react native with redux
CS101- Introduction to Computing- Lecture 32
JS Essence
Andrii Sliusar "Module Architecture of React-Redux Applications"
javascript Event Handling and introduction to event.ppt
What’s expected in Spring 5
Single Page Applications: Your Browser is the OS!
An Overview of the React Ecosystem
IP Unit 2.pptx
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
Flopsar tesacom-technical-introduction v1a-eng
All about that reactive ui
Event Programming JavaScript
Microservices: The Best Practices
Spring batch
DBmaestro's State of the Database Continuous Delivery Survey- Findings Revealed
Ad

More from Grid Dynamics (20)

PPTX
Are you keeping up with your customer
PPTX
"Implementing data quality automation with open source stack" - Max Martynov,...
PDF
"How to build cool & useful voice commerce applications (such as devices like...
PPTX
"Challenges for AI in Healthcare" - Peter Graven Ph.D
PPTX
Dynamic Talks: "Applications of Big Data, Machine Learning and Artificial Int...
PPTX
Dynamic Talks: "Digital Transformation in Banking & Financial Services… a per...
PDF
Dynamic Talks: "Data Strategy as a Conduit for Data Maturity and Monetization...
PDF
Dynamics Talks: "Writing Spark Pipelines with Less Boilerplate Code" - Egor P...
PPTX
"Trends in Building Advanced Analytics Platform for Large Enterprises" - Atul...
PPTX
The New Era of Public Safety Records Management: Dynamic talks Chicago 9/24/2019
PPTX
Dynamic Talks: "Implementing data quality automation with open source stack" ...
PDF
"Implementing AI for New Business Models and Efficiencies" - Parag Shrivastav...
PPTX
Reducing No-shows and Late Cancelations in Healthcare Enterprise" - Shervin M...
PDF
Customer intelligence: a Machine Learning Approach: Dynamic talks Atlanta 8/2...
PPTX
"ML Services - How do you begin and when do you start scaling?" - Madhura Dud...
PPTX
Realtime Contextual Product Recommendations…that scale and generate revenue -...
PDF
Decision Automation in Marketing Systems using Reinforcement Learning: Dynami...
PPTX
Best practices for enterprise-grade microservices implementations with Google...
PPTX
Attribution Modelling 101: Credit Where Credit is Due!: Dynamic talks Seattle...
PDF
Building an algorithmic price management system using ML: Dynamic talks Seatt...
Are you keeping up with your customer
"Implementing data quality automation with open source stack" - Max Martynov,...
"How to build cool & useful voice commerce applications (such as devices like...
"Challenges for AI in Healthcare" - Peter Graven Ph.D
Dynamic Talks: "Applications of Big Data, Machine Learning and Artificial Int...
Dynamic Talks: "Digital Transformation in Banking & Financial Services… a per...
Dynamic Talks: "Data Strategy as a Conduit for Data Maturity and Monetization...
Dynamics Talks: "Writing Spark Pipelines with Less Boilerplate Code" - Egor P...
"Trends in Building Advanced Analytics Platform for Large Enterprises" - Atul...
The New Era of Public Safety Records Management: Dynamic talks Chicago 9/24/2019
Dynamic Talks: "Implementing data quality automation with open source stack" ...
"Implementing AI for New Business Models and Efficiencies" - Parag Shrivastav...
Reducing No-shows and Late Cancelations in Healthcare Enterprise" - Shervin M...
Customer intelligence: a Machine Learning Approach: Dynamic talks Atlanta 8/2...
"ML Services - How do you begin and when do you start scaling?" - Madhura Dud...
Realtime Contextual Product Recommendations…that scale and generate revenue -...
Decision Automation in Marketing Systems using Reinforcement Learning: Dynami...
Best practices for enterprise-grade microservices implementations with Google...
Attribution Modelling 101: Credit Where Credit is Due!: Dynamic talks Seattle...
Building an algorithmic price management system using ML: Dynamic talks Seatt...
Ad

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PPT
Teaching material agriculture food technology
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Machine learning based COVID-19 study performance prediction
PPTX
A Presentation on Artificial Intelligence
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Cloud computing and distributed systems.
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation theory and applications.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
NewMind AI Monthly Chronicles - July 2025
Electronic commerce courselecture one. Pdf
Teaching material agriculture food technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Machine learning based COVID-19 study performance prediction
A Presentation on Artificial Intelligence
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Review of recent advances in non-invasive hemoglobin estimation
Cloud computing and distributed systems.
Diabetes mellitus diagnosis method based random forest with bat algorithm
Mobile App Security Testing_ A Comprehensive Guide.pdf
Big Data Technologies - Introduction.pptx
Empathic Computing: Creating Shared Understanding
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation theory and applications.pdf
Unlocking AI with Model Context Protocol (MCP)
NewMind AI Weekly Chronicles - August'25 Week I
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
NewMind AI Monthly Chronicles - July 2025

MobX: the way to simplicity