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
86
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
120
Other Decks in Technology
See All in Technology
3つのアプローチで目指す チームを強くするAI駆動開発
thkt
0
140
freeeらしさをAIとともに作る / Creating the freee Experience with AI
ymrl
0
220
転んだ話が背中を預ける理由になる / A_story_about_falling_down_gives_you_a_reason_to_watch_each_other_s_backs.pdf
pauli
3
340
Claude Code本は、どのように執筆チームで書かれたか
oikon48
1
350
12 個 Tool と、 4,096 Token
hlum
0
110
継続的なAIコスト最適化
bgpat
1
270
Kiro Crewをはじめよう
kizawa2020
1
110
味覇で作るパスタが美味い - 20261001_yabaubuki.dev
livesense
PRO
0
110
オブザーバビリティを高める AI エージェント体験を考える / Designing AI Agent Experiences That Enhance Observability
aoto
PRO
2
320
go-sqletch
moznion
0
120
The seven pitfalls of AI (revised version)
ufried
0
310
Deep Data Security 機能解説
oracle4engineer
PRO
2
740
Featured
See All Featured
[SF Ruby Conf 2025] Rails X
palkan
3
1.4k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
730
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
The Cost Of JavaScript in 2023
addyosmani
55
10k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
540
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
490
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
310
Optimising Largest Contentful Paint
csswizardry
37
4k
A designer walks into a library…
pauljervisheath
211
25k
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