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

What's hot (20)

PPTX
Selenium with protractor
BOGA HARIKRISHNA
 
PDF
Viktor Turskyi "Effective NodeJS Application Development"
Fwdays
 
ODP
Springboot and camel
Deepak Kumar
 
ODP
Eclipse Buildship JUG Hamburg
simonscholz
 
PDF
AngularJS + React
justvamp
 
PDF
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)
🎤 Hanno Embregts 🎸
 
ODP
Eclipse Mars News @JUG HH
simonscholz
 
PDF
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Zach Lendon
 
PDF
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
Zach Lendon
 
PDF
Migrating 25K lines of Ant scripting to Gradle
🎤 Hanno Embregts 🎸
 
PDF
ReactJS vs AngularJS - Head to Head comparison
500Tech
 
PDF
Angular js - 10 reasons to choose angularjs
Nir Kaufman
 
PPTX
Angular 2 in-1
GlobalLogic Ukraine
 
PDF
No more waiting for API - Android Stub Server
Sylwester Madej
 
PDF
jQuery plugin & testing with Jasmine
Miguel Parramón Teixidó
 
PPTX
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Deepu S Nath
 
PPT
ColdFusion Components
jsmith
 
PPTX
AOT(Ahead Of Time)
Questpond
 
PPTX
Building Reliable Applications Using React, .NET & Azure
Maurice De Beijer [MVP]
 
PDF
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Codemotion
 
Selenium with protractor
BOGA HARIKRISHNA
 
Viktor Turskyi "Effective NodeJS Application Development"
Fwdays
 
Springboot and camel
Deepak Kumar
 
Eclipse Buildship JUG Hamburg
simonscholz
 
AngularJS + React
justvamp
 
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)
🎤 Hanno Embregts 🎸
 
Eclipse Mars News @JUG HH
simonscholz
 
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Zach Lendon
 
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
Zach Lendon
 
Migrating 25K lines of Ant scripting to Gradle
🎤 Hanno Embregts 🎸
 
ReactJS vs AngularJS - Head to Head comparison
500Tech
 
Angular js - 10 reasons to choose angularjs
Nir Kaufman
 
Angular 2 in-1
GlobalLogic Ukraine
 
No more waiting for API - Android Stub Server
Sylwester Madej
 
jQuery plugin & testing with Jasmine
Miguel Parramón Teixidó
 
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Deepu S Nath
 
ColdFusion Components
jsmith
 
AOT(Ahead Of Time)
Questpond
 
Building Reliable Applications Using React, .NET & Azure
Maurice De Beijer [MVP]
 
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Codemotion
 

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
Ali Sa'o
 
PDF
React Internals - How understanding React implementation can help us write be...
Ankit Muchhala
 
PDF
JOSA TechTalks - Better Web Apps with React and Redux
Jordan Open Source Association
 
PDF
React & Flux Workshop
Christian Lilley
 
PPTX
Reactjs A javascript Library
Mohit Jain
 
PPTX
React.js at Cortex
Geoff Harcourt
 
PDF
Workshop 19: ReactJS Introduction
Visual Engineering
 
PDF
Reduxing UI: Borrowing the Best of Web to Make Android Better
Christina Lee
 
PDF
Patterns For React Application Design
Ian Thomas
 
PDF
The Road To Redux
Jeffrey Sanchez
 
PPTX
ReactJS
Ram Murat Sharma
 
PDF
An Intense Overview of the React Ecosystem
Rami Sayar
 
PPTX
React learning in the hard way
Chen Feldman
 
PPTX
20171108 PDN HOL React Basics
Rich Ross
 
PDF
I Heard React Was Good
FITC
 
PDF
Welcome to React & Flux !
Ritesh Kumar
 
PDF
React.js alternatives modern web frameworks and lightweight java script libr...
Katy Slemon
 
PDF
Towards component based web UI with ReactJS
Oliver Häger
 
PDF
Getting Started with React, When You’re an Angular Developer
Fabrit Global
 
PPTX
React, Flux and a little bit of Redux
Ny Fanilo Andrianjafy, B.Eng.
 
Better web apps with React and Redux
Ali Sa'o
 
React Internals - How understanding React implementation can help us write be...
Ankit Muchhala
 
JOSA TechTalks - Better Web Apps with React and Redux
Jordan Open Source Association
 
React & Flux Workshop
Christian Lilley
 
Reactjs A javascript Library
Mohit Jain
 
React.js at Cortex
Geoff Harcourt
 
Workshop 19: ReactJS Introduction
Visual Engineering
 
Reduxing UI: Borrowing the Best of Web to Make Android Better
Christina Lee
 
Patterns For React Application Design
Ian Thomas
 
The Road To Redux
Jeffrey Sanchez
 
An Intense Overview of the React Ecosystem
Rami Sayar
 
React learning in the hard way
Chen Feldman
 
20171108 PDN HOL React Basics
Rich Ross
 
I Heard React Was Good
FITC
 
Welcome to React & Flux !
Ritesh Kumar
 
React.js alternatives modern web frameworks and lightweight java script libr...
Katy Slemon
 
Towards component based web UI with ReactJS
Oliver Häger
 
Getting Started with React, When You’re an Angular Developer
Fabrit Global
 
React, Flux and a little bit of Redux
Ny Fanilo Andrianjafy, B.Eng.
 
Ad

More from Fwdays (20)

PPTX
"Як ми переписали Сільпо на Angular", Євген Русаков
Fwdays
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
"Validation and Observability of AI Agents", Oleksandr Denisyuk
Fwdays
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
"Co-Authoring with a Machine: What I Learned from Writing a Book on Generativ...
Fwdays
 
PPTX
"Human-AI Collaboration Models for Better Decisions, Faster Workflows, and Cr...
Fwdays
 
PDF
"AI is already here. What will happen to your team (and your role) tomorrow?"...
Fwdays
 
PPTX
"Is it worth investing in AI in 2025?", Alexander Sharko
Fwdays
 
PDF
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
PDF
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
PDF
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
PDF
"Scaling in space and time with Temporal", Andriy Lupa .pdf
Fwdays
 
PPTX
"Provisioning via DOT-Chain: from catering to drone marketplaces", Volodymyr ...
Fwdays
 
PPTX
" Observability with Elasticsearch: Best Practices for High-Load Platform", A...
Fwdays
 
PPTX
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
PPTX
"Istio Ambient Mesh in production: our way from Sidecar to Sidecar-less",Hlib...
Fwdays
 
PPTX
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
PPTX
"Confidential AI: zero trust concept", Hennadiy Karpov
Fwdays
 
PPTX
"Choosing Tensor Accelerators for Specific Tasks: Compute vs Memory Bound Mod...
Fwdays
 
"Як ми переписали Сільпо на Angular", Євген Русаков
Fwdays
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
"Validation and Observability of AI Agents", Oleksandr Denisyuk
Fwdays
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
"Co-Authoring with a Machine: What I Learned from Writing a Book on Generativ...
Fwdays
 
"Human-AI Collaboration Models for Better Decisions, Faster Workflows, and Cr...
Fwdays
 
"AI is already here. What will happen to your team (and your role) tomorrow?"...
Fwdays
 
"Is it worth investing in AI in 2025?", Alexander Sharko
Fwdays
 
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
"Scaling in space and time with Temporal", Andriy Lupa .pdf
Fwdays
 
"Provisioning via DOT-Chain: from catering to drone marketplaces", Volodymyr ...
Fwdays
 
" Observability with Elasticsearch: Best Practices for High-Load Platform", A...
Fwdays
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
"Istio Ambient Mesh in production: our way from Sidecar to Sidecar-less",Hlib...
Fwdays
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
"Confidential AI: zero trust concept", Hennadiy Karpov
Fwdays
 
"Choosing Tensor Accelerators for Specific Tasks: Compute vs Memory Bound Mod...
Fwdays
 
Ad

Recently uploaded (20)

PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 

"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