Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Single State Atom apps
Search
Rogério Chaves
December 02, 2015
Technology
200
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Single State Atom apps
If state is the root of all evil, why don't we put it right on the root?
I'll show 3 examples
Rogério Chaves
December 02, 2015
More Decks by Rogério Chaves
See All by Rogério Chaves
O problema das Fake News
rogeriochaves
1
210
A Brief History of Frontend
rogeriochaves
1
88
Implementando PWA em qualquer projeto
rogeriochaves
2
230
Microfrontends
rogeriochaves
2
150
Introducción a Elm
rogeriochaves
0
84
Immutable App Architecture
rogeriochaves
0
240
Faça programação funcional com JavaScript codando menos
rogeriochaves
4
530
Introduction to Elm
rogeriochaves
2
170
Playing with RxJS
rogeriochaves
0
130
Other Decks in Technology
See All in Technology
Draft AIエージェントの トークン消費を最小化する 8つの原則
kinopeee
6
1.9k
AI時代、つくる力を自分たちの手に。 ──電通×KAG、アジャイルとAI駆動開発で挑む開発の変革
yuukiyo
3
440
正解のない研修に放り出されて / Being thrown into a training program with no right answers
ohnoeight
1
170
Snowflake でできることが増えたら、 ABAC が必要になった
kaeton
0
120
契約で守るコンパウンドプロダクトのデザインシステム
yug1224
1
1.6k
ひとりで始めた AI駆動開発、チームに広げて何が変わったのか
kenichiodo
1
170
バイブコーディングの特徴と「コケて直す」ループ
happysamurai294
0
130
You Have Agency(サンキュー、Ruby)
snoozer05
PRO
4
620
キヨさん67歳 AIコーディングエージェント物語
happysamurai294
0
140
1週間、Opus封印でお願いします
kintotechdev
0
400
Flutter Webを「SDK」として配る — 50以上のゲームを支える埋め込みアーキテクチャ
masayukisuda
0
160
複雑な業務システムを高速でつくるため、チーム全員をつくれる人へ
ayakurabuchi
0
110
Featured
See All Featured
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
600
WENDY [Excerpt]
tessaabrams
14
40k
Designing for humans not robots
tammielis
254
26k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
320
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
My Coaching Mixtape
mlcsv
0
370
Are puppies a ranking factor?
jonoalderson
2
4.1k
Transcript
SINGLE STATE ATOM APPS
2 state = if
3 why don’t we put it right on the root?
THE IDEA 4 main <foo> <bar> <qux> state •State lives
on the root •Pass below only what matters •Components just render what it receives, no side-effects
5 BUT HOW DO WE UPDATE THE STATE?
REACT + CURSOR 6 or atom, or zipper
REACT + CURSOR 7 <List items={cursor.refine('items')} /> const List =
(props) => <ul> {props.items.map(ListItem)} </ul> const ListItem = (item) => <li> {item.refine('name').value} <NameInput name={item.refine('name')} /> </li> const NameInput = (props) => <input value={props.name.value} onChange={props.name.set} /> (not an actual implementation)
CLOJURESCRIPT + OM Single state atom 8
9 AWESOME DEMO https://youtu.be/5yHFTN-_mOo
10 TODOMVC EXAMPLE
REACT + REDUX 11 Reduce FTW R
WHAT IS A REDUCER? 12 const list = [1, 2,
3] list.reduce((accumulated, current) => { return accumulated + current }, 5) // 11
REDUX STRUCTURE 13 main <foo> <bar> <qux> state actions user
input reduce onChange
HOW REDUX WORKS 14 const state = { list: [{name:
"une"}, {name: "due"}] }; const actions = [{type: "ADD", name: "tre"}]; const reducer = (currentState, action) => { switch (action.type) { case "ADD": return { list: [...currentState.list, {name: action.name}) } default: return currentState; } } actions.reduce(reducer, state); /* { list: [{name: "une"}, {name: "due"}, {name: "tre"}] }; */
15 TODOMVC EXAMPLE
16 REDUX DEVTOOLS
ELM 17 The right way is the only way
18 EXAMPLE
ADVANTAGES 19 •Single source of truth •Deterministic state changes •Rationalise
about the rendered UI •State change timeline •Easier to debug •Hot reloading (example) •Fast rendering •Easier to implement optimistic updates •Easier to have an isomorphic app •Simple functions and data structures
20 WHY IS THIS HAPPENING ON FRONT-END?
21 EXAMPLES SOURCE CODE github.com/rogeriochaves/single-state-atom-apps
THANK YOU