SlideShare a Scribd company logo
"The Story of Declarative React at Grammarly: From two-way data binding with Focal to a custom implementation of UI as a tree data structure", Oleksandr Suhak
What we do
Outline
● Focal: good and bad points
● Reusability problems
● Experimental challenges
● Embrace: the solution to the above
● The current state of things
Let’s start with
https://github.com/grammarly/focal
Focal enables “two-way binding”
But two-way binding has
some issues
● Hard to reuse components: coupling of View and
Model logic
● Hard to do action—generic logic: logging,
filtering, throttling, etc.
Action messages are better
Action messages are better
Action messages are better
Action messages are better
The way we do state
management
● Component state inside an Atom
● Component publishes actions
● State manager/VM listens for actions and
updates state
● Rx.js: complex side effects management and
synchronization of states
● Fp-ts: complex state updates
Problem: nested state
Problem: nested actions
Problem: uncontrolled side effects
Solution hints:
● First-class support for action messages
● Better state composition
● Better action composition
Maintainability
Props interface on component?
Or state interface on manager?
Solution hints:
● One place to define state and action interfaces
● VM <- UI is bad
● VM -> UI is good
Experiments
A/B
Experiments with if-else
If-elsing problems
● It scales badly (think >100 experiments)
● Easy to add, hard to remove
● Easy to introduce experiment conflicts
● Need to involve multiple teams to do each
experiment
Solution hints:
● UI as a traversable data structure
● Experiment as a function from one UI to another
● Type safe UI changes to avoid breaking changes
Introducing Embrace
● “Embrace” as in “hug the UI and squeeze any last bit of side effects
from it”
Introducing Embrace
● “Embrace” as in “hug the UI and squeeze any last bit of side effects
from it”
● A library for UI composition with a focus on type safety and
immutability
● Makes UI representation truly declarative
● Uses React but triggers re-renders via Rx.js observables and Focal
internally instead of relying on React’s VDOM
UI Part
UI Part
S S S
Obs<State>
A A A
Obs<Actions>
UIPart
Flow
Flow S S S
Obs<State>
S S S
Obs<Actions>
Flow
Mounting
● Given a UIPart
● And a Flow that matches in action/state types
● Embrace can “mount” it
● Producing the ReactElement
● mount(UIPart, Flow) = ReactElement
Embrace app model
Counter Example
Counter Example
Unlike:
● Pure react Embrace is declarative; no side
effects allowed in components (No hooks! Well,
maybe a few)
● Redux: no single state; everything is observable
by default; no need to manually pass props
● Cycle.js Embrace is type safe, does not rely on
selectors, is declarative
Composing UI parts
UI Part UI Part
UI Part
Composing UI parts
● A programmer who uses Embrace composes an App’s UI from smaller UI
Parts
● Node: a UI Part that does not have slots
● Grid: the same as a Node but has named slots
● Knot: fills in a Grid’s slots with other UI Parts
● List: renders the collection of parts
● Union: renders one part at a time from a union of parts
● etc.
Composing UI parts
Composing UI parts
Patching UI with Embrace
App New App
Patch
Patching UI with Embrace
Experiments through Patching
Tales from production
Tales from production
Tales from production
Tales from production
Tales from production
Tales from production
Tales from production
Tales from production
Tales from production
Embrace today
● Spreads through Grammarly UI platform
● Used by Grammarly Extension and Web Editor
● Continues to evolve
● Not ready for public release yet
● Challenges: animations, lists, animations in lists
● Gives us truly declarative UI logic that composes
● Provides our and other Grammarly teams full
control of the UI after we reuse Embrace
components
● Allows us to manage breaking changes
Embrace today
Join us!
Help make Embrace and other cool stuff!
Thank you!

More Related Content

PPTX
Migration from AngularJS to Angular
PDF
Angular 2 vs React
PPTX
Олексій Гончар "Використання Electron в розробці корпоративної відео-мессeндж...
PPTX
Branching Strategies For Git and Subversion
PDF
Angular 2 vs React. What to chose in 2017?
DOCX
Protractor end-to-end testing framework for angular js
PDF
ReactJS or Angular
PDF
React vs angular (mobile first battle)
Migration from AngularJS to Angular
Angular 2 vs React
Олексій Гончар "Використання Electron в розробці корпоративної відео-мессeндж...
Branching Strategies For Git and Subversion
Angular 2 vs React. What to chose in 2017?
Protractor end-to-end testing framework for angular js
ReactJS or Angular
React vs angular (mobile first battle)

What's hot (20)

PPTX
Selenium with protractor
PDF
Viktor Turskyi "Effective NodeJS Application Development"
ODP
Springboot and camel
ODP
Eclipse Buildship JUG Hamburg
PDF
AngularJS + React
PDF
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)
ODP
Eclipse Mars News @JUG HH
PDF
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
PDF
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
PDF
Migrating 25K lines of Ant scripting to Gradle
PDF
ReactJS vs AngularJS - Head to Head comparison
PDF
Angular js - 10 reasons to choose angularjs
PPTX
Angular 2 in-1
PDF
No more waiting for API - Android Stub Server
PDF
jQuery plugin & testing with Jasmine
PPTX
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
PPT
ColdFusion Components
PPTX
AOT(Ahead Of Time)
PPTX
Building Reliable Applications Using React, .NET & Azure
PDF
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Selenium with protractor
Viktor Turskyi "Effective NodeJS Application Development"
Springboot and camel
Eclipse Buildship JUG Hamburg
AngularJS + React
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)
Eclipse Mars News @JUG HH
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
Migrating 25K lines of Ant scripting to Gradle
ReactJS vs AngularJS - Head to Head comparison
Angular js - 10 reasons to choose angularjs
Angular 2 in-1
No more waiting for API - Android Stub Server
jQuery plugin & testing with Jasmine
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
ColdFusion Components
AOT(Ahead Of Time)
Building Reliable Applications Using React, .NET & Azure
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Ad

Similar to "The Story of Declarative React at Grammarly: From two-way data binding with Focal to a custom implementation of UI as a tree data structure", Oleksandr Suhak (20)

PPTX
Better web apps with React and Redux
PDF
React Internals - How understanding React implementation can help us write be...
PDF
JOSA TechTalks - Better Web Apps with React and Redux
PDF
React & Flux Workshop
PPTX
Reactjs A javascript Library
PPTX
React.js at Cortex
PDF
Workshop 19: ReactJS Introduction
PDF
Reduxing UI: Borrowing the Best of Web to Make Android Better
PDF
Patterns For React Application Design
PDF
The Road To Redux
PPTX
PDF
An Intense Overview of the React Ecosystem
PPTX
React learning in the hard way
PPTX
20171108 PDN HOL React Basics
PDF
I Heard React Was Good
PDF
Welcome to React & Flux !
PDF
React.js alternatives modern web frameworks and lightweight java script libr...
PDF
Towards component based web UI with ReactJS
PDF
Getting Started with React, When You’re an Angular Developer
PPTX
React, Flux and a little bit of Redux
Better web apps with React and Redux
React Internals - How understanding React implementation can help us write be...
JOSA TechTalks - Better Web Apps with React and Redux
React & Flux Workshop
Reactjs A javascript Library
React.js at Cortex
Workshop 19: ReactJS Introduction
Reduxing UI: Borrowing the Best of Web to Make Android Better
Patterns For React Application Design
The Road To Redux
An Intense Overview of the React Ecosystem
React learning in the hard way
20171108 PDN HOL React Basics
I Heard React Was Good
Welcome to React & Flux !
React.js alternatives modern web frameworks and lightweight java script libr...
Towards component based web UI with ReactJS
Getting Started with React, When You’re an Angular Developer
React, Flux and a little bit of Redux
Ad

More from Fwdays (20)

PDF
"Mastering UI Complexity: State Machines and Reactive Patterns at Grammarly",...
PDF
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
PPTX
"Computer Use Agents: From SFT to Classic RL", Maksym Shamrai
PPTX
"Як ми переписали Сільпо на Angular", Євген Русаков
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
PDF
"Validation and Observability of AI Agents", Oleksandr Denisyuk
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
PPTX
"Co-Authoring with a Machine: What I Learned from Writing a Book on Generativ...
PPTX
"Human-AI Collaboration Models for Better Decisions, Faster Workflows, and Cr...
PDF
"AI is already here. What will happen to your team (and your role) tomorrow?"...
PPTX
"Is it worth investing in AI in 2025?", Alexander Sharko
PDF
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
PDF
"Scaling in space and time with Temporal", Andriy Lupa.pdf
PDF
"Database isolation: how we deal with hundreds of direct connections to the d...
PDF
"Scaling in space and time with Temporal", Andriy Lupa .pdf
PPTX
"Provisioning via DOT-Chain: from catering to drone marketplaces", Volodymyr ...
PPTX
" Observability with Elasticsearch: Best Practices for High-Load Platform", A...
PPTX
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
PPTX
"Istio Ambient Mesh in production: our way from Sidecar to Sidecar-less",Hlib...
"Mastering UI Complexity: State Machines and Reactive Patterns at Grammarly",...
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
"Computer Use Agents: From SFT to Classic RL", Maksym Shamrai
"Як ми переписали Сільпо на Angular", Євген Русаков
"AI Transformation: Directions and Challenges", Pavlo Shaternik
"Validation and Observability of AI Agents", Oleksandr Denisyuk
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
"Co-Authoring with a Machine: What I Learned from Writing a Book on Generativ...
"Human-AI Collaboration Models for Better Decisions, Faster Workflows, and Cr...
"AI is already here. What will happen to your team (and your role) tomorrow?"...
"Is it worth investing in AI in 2025?", Alexander Sharko
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Database isolation: how we deal with hundreds of direct connections to the d...
"Scaling in space and time with Temporal", Andriy Lupa .pdf
"Provisioning via DOT-Chain: from catering to drone marketplaces", Volodymyr ...
" Observability with Elasticsearch: Best Practices for High-Load Platform", A...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"Istio Ambient Mesh in production: our way from Sidecar to Sidecar-less",Hlib...

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPT
Teaching material agriculture food technology
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Spectroscopy.pptx food analysis technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Unlocking AI with Model Context Protocol (MCP)
“AI and Expert System Decision Support & Business Intelligence Systems”
NewMind AI Weekly Chronicles - August'25 Week I
Chapter 3 Spatial Domain Image Processing.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Teaching material agriculture food technology
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Programs and apps: productivity, graphics, security and other tools
20250228 LYD VKU AI Blended-Learning.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
The AUB Centre for AI in Media Proposal.docx
Spectroscopy.pptx food analysis technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
MIND Revenue Release Quarter 2 2025 Press Release
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Unlocking AI with Model Context Protocol (MCP)

"The Story of Declarative React at Grammarly: From two-way data binding with Focal to a custom implementation of UI as a tree data structure", Oleksandr Suhak