SlideShare una empresa de Scribd logo
1 de 22
Descargar para leer sin conexión
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>
stateactions
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

Más contenido relacionado

Destacado

SPI Annual Meeting Recognition List (New)
SPI Annual Meeting Recognition List (New)SPI Annual Meeting Recognition List (New)
SPI Annual Meeting Recognition List (New)spisolutions
 
เครื่องใช้ไฟฟ้าในปัจจุบัน
เครื่องใช้ไฟฟ้าในปัจจุบันเครื่องใช้ไฟฟ้าในปัจจุบัน
เครื่องใช้ไฟฟ้าในปัจจุบันNatdanai Kumpao
 
People. nature and portraits pics
People. nature and portraits picsPeople. nature and portraits pics
People. nature and portraits picsHira Farooq
 
Something to Give, Something to Gain
Something to Give, Something to GainSomething to Give, Something to Gain
Something to Give, Something to Gainspisolutions
 
Jan lokpal tamil by mohan-mba-sasurie
Jan lokpal tamil by mohan-mba-sasurieJan lokpal tamil by mohan-mba-sasurie
Jan lokpal tamil by mohan-mba-sasurieMohan Kumar
 
Destributed RES power gen in Greece incentives [2011]
Destributed RES power gen in Greece incentives [2011]Destributed RES power gen in Greece incentives [2011]
Destributed RES power gen in Greece incentives [2011]Constantinos Faitatzoglou
 
Paper caso cinco terra con Daniella Mazzonis y Marco Dini
Paper caso cinco terra con Daniella Mazzonis y Marco DiniPaper caso cinco terra con Daniella Mazzonis y Marco Dini
Paper caso cinco terra con Daniella Mazzonis y Marco DiniConectaDEL
 
Finalculturaladventure
FinalculturaladventureFinalculturaladventure
Finalculturaladventure14771
 

Destacado (15)

Self-testing Code
Self-testing CodeSelf-testing Code
Self-testing Code
 
Introduction to Elm
Introduction to ElmIntroduction to Elm
Introduction to Elm
 
Playing with RxJS
Playing with RxJSPlaying with RxJS
Playing with RxJS
 
SPI Annual Meeting Recognition List (New)
SPI Annual Meeting Recognition List (New)SPI Annual Meeting Recognition List (New)
SPI Annual Meeting Recognition List (New)
 
เครื่องใช้ไฟฟ้าในปัจจุบัน
เครื่องใช้ไฟฟ้าในปัจจุบันเครื่องใช้ไฟฟ้าในปัจจุบัน
เครื่องใช้ไฟฟ้าในปัจจุบัน
 
People. nature and portraits pics
People. nature and portraits picsPeople. nature and portraits pics
People. nature and portraits pics
 
Woollen Shaggy
Woollen ShaggyWoollen Shaggy
Woollen Shaggy
 
Texture Rugs Tulsiram
Texture Rugs TulsiramTexture Rugs Tulsiram
Texture Rugs Tulsiram
 
Something to Give, Something to Gain
Something to Give, Something to GainSomething to Give, Something to Gain
Something to Give, Something to Gain
 
Jan lokpal tamil by mohan-mba-sasurie
Jan lokpal tamil by mohan-mba-sasurieJan lokpal tamil by mohan-mba-sasurie
Jan lokpal tamil by mohan-mba-sasurie
 
Világos?!...
Világos?!...Világos?!...
Világos?!...
 
Ecommerce 101
Ecommerce 101Ecommerce 101
Ecommerce 101
 
Destributed RES power gen in Greece incentives [2011]
Destributed RES power gen in Greece incentives [2011]Destributed RES power gen in Greece incentives [2011]
Destributed RES power gen in Greece incentives [2011]
 
Paper caso cinco terra con Daniella Mazzonis y Marco Dini
Paper caso cinco terra con Daniella Mazzonis y Marco DiniPaper caso cinco terra con Daniella Mazzonis y Marco Dini
Paper caso cinco terra con Daniella Mazzonis y Marco Dini
 
Finalculturaladventure
FinalculturaladventureFinalculturaladventure
Finalculturaladventure
 

Similar a Single State Atom apps

JAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docx
JAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docxJAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docx
JAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docxGavinUJtMathist
 
A Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOA Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOJorge Vásquez
 
Stacks,queues,linked-list
Stacks,queues,linked-listStacks,queues,linked-list
Stacks,queues,linked-listpinakspatel
 
React performance tips, Тельман Агабабов
React performance tips, Тельман АгабабовReact performance tips, Тельман Агабабов
React performance tips, Тельман АгабабовSigma Software
 
Mobx Performance and Sanity
Mobx Performance and SanityMobx Performance and Sanity
Mobx Performance and Sanity500Tech
 
Array data structure
Array data structureArray data structure
Array data structureharsh112327
 
Array data structure
Array data structureArray data structure
Array data structuremaamir farooq
 
Stack and its applications
Stack and its applicationsStack and its applications
Stack and its applicationsAhsan Mansiv
 
Stacks in DATA STRUCTURE
Stacks in DATA STRUCTUREStacks in DATA STRUCTURE
Stacks in DATA STRUCTUREMandeep Singh
 
A Skeptics guide to functional style javascript
A Skeptics guide to functional style javascriptA Skeptics guide to functional style javascript
A Skeptics guide to functional style javascriptjonathanfmills
 
Hi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfHi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfannaelctronics
 
c++Write a program to test the selection sort algorithm for array-.pdf
c++Write a program to test the selection sort algorithm for array-.pdfc++Write a program to test the selection sort algorithm for array-.pdf
c++Write a program to test the selection sort algorithm for array-.pdfakpatra2000
 
Create a JAVA Program that traverses through an array recursively- rat.docx
Create a JAVA Program that traverses through an array recursively- rat.docxCreate a JAVA Program that traverses through an array recursively- rat.docx
Create a JAVA Program that traverses through an array recursively- rat.docxmrichard5
 
Write a program to find the number of comparisons using the binary se.docx
 Write a program to find the number of comparisons using the binary se.docx Write a program to find the number of comparisons using the binary se.docx
Write a program to find the number of comparisons using the binary se.docxajoy21
 
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...
Below is a given ArrayList class and Main class  Your Dreams Our Mission/tuto...Below is a given ArrayList class and Main class  Your Dreams Our Mission/tuto...
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...davidwarner122
 
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdfimplement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdfFOREVERPRODUCTCHD
 
BackgroundIn many applications, the composition of a collection o.pdf
BackgroundIn many applications, the composition of a collection o.pdfBackgroundIn many applications, the composition of a collection o.pdf
BackgroundIn many applications, the composition of a collection o.pdfmayorothenguyenhob69
 

Similar a Single State Atom apps (20)

JAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docx
JAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docxJAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docx
JAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docx
 
A Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOA Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIO
 
Stacks,queues,linked-list
Stacks,queues,linked-listStacks,queues,linked-list
Stacks,queues,linked-list
 
React performance tips, Тельман Агабабов
React performance tips, Тельман АгабабовReact performance tips, Тельман Агабабов
React performance tips, Тельман Агабабов
 
Mobx Performance and Sanity
Mobx Performance and SanityMobx Performance and Sanity
Mobx Performance and Sanity
 
Array data structure
Array data structureArray data structure
Array data structure
 
Array data structure
Array data structureArray data structure
Array data structure
 
Stack and its applications
Stack and its applicationsStack and its applications
Stack and its applications
 
Unit 3 stack
Unit 3   stackUnit 3   stack
Unit 3 stack
 
Stacks in DATA STRUCTURE
Stacks in DATA STRUCTUREStacks in DATA STRUCTURE
Stacks in DATA STRUCTURE
 
Java Generics
Java GenericsJava Generics
Java Generics
 
A Skeptics guide to functional style javascript
A Skeptics guide to functional style javascriptA Skeptics guide to functional style javascript
A Skeptics guide to functional style javascript
 
Hi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdfHi,I have added the methods and main class as per your requirement.pdf
Hi,I have added the methods and main class as per your requirement.pdf
 
c++Write a program to test the selection sort algorithm for array-.pdf
c++Write a program to test the selection sort algorithm for array-.pdfc++Write a program to test the selection sort algorithm for array-.pdf
c++Write a program to test the selection sort algorithm for array-.pdf
 
Create a JAVA Program that traverses through an array recursively- rat.docx
Create a JAVA Program that traverses through an array recursively- rat.docxCreate a JAVA Program that traverses through an array recursively- rat.docx
Create a JAVA Program that traverses through an array recursively- rat.docx
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
 
Write a program to find the number of comparisons using the binary se.docx
 Write a program to find the number of comparisons using the binary se.docx Write a program to find the number of comparisons using the binary se.docx
Write a program to find the number of comparisons using the binary se.docx
 
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...
Below is a given ArrayList class and Main class  Your Dreams Our Mission/tuto...Below is a given ArrayList class and Main class  Your Dreams Our Mission/tuto...
Below is a given ArrayList class and Main class Your Dreams Our Mission/tuto...
 
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdfimplement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
 
BackgroundIn many applications, the composition of a collection o.pdf
BackgroundIn many applications, the composition of a collection o.pdfBackgroundIn many applications, the composition of a collection o.pdf
BackgroundIn many applications, the composition of a collection o.pdf
 

Último

Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durbanmasabamasaba
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
 

Último (20)

Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 

Single State Atom apps