SlideShare ist ein Scribd-Unternehmen logo
1 von 31
The Redux State
of the Art
Limor Mekaiten & Shem Magnezi
Managing
app state
We were all there
We
were
there
too
Facebook
we have a
problem
Introducing Flux
Then came Redux
Redux data flow
Store
Components / Views
Actions
Reducer
Let’s dive in
(in Kotlin)
data class AppState(val unreadConut: Int,
val notifications: List<Notification>)
Store
Store.init(AppState.new(0, emptyList()))
Store
//Notifications Activity
fun onCreate() {
Store.subscribe(this)
}
fun onStateChange(newState: AppState) {
notificationRecycleView.setNotifications(
newState.notifications)
}
View
data class MarkAllAsReadAction()
data class AddNotificationAction(notification:
Notification)
Actions
//Notifications Activity
markAllAsReadButton.onClick(click => {
Store.dispatch(MarkAsReadAction.new())
})
Actions
fun reduce(oldState: AppState, action: Action) : AppState {
return when (action) {
is MarkAllAsRead -> {
return oldState.copy(unreadConut = 0)
}
else -> oldState
}
}
Reducers
//Notifications ServiceWorker
fun onMessageReceived(remoteMessage: RemoteMessage) {
val notificationFromServer = Notificaiton.new(remoteMessage.msg)
Store.dispatch(AddNotificationAction.new(notificationFromServer))
}
Actions
fun reduce(oldState: AppState, action: Action) : AppState {
return when (action) {
is AddNotificationAction -> {
return oldState.copy(
unreadConut = oldState.unreadConut + 1,
notifications = action.notification +
oldState.notifications)
}
...
else -> oldState
}
}
Reducers
Redux data flow (again)
Redux - Why is it good for me?
Logic is made easy
● Implicit data flow of your app becomes explicit
● Easy to spot edge cases - you get to see the missing
cases now
Debugging is made easy
● Single source of truth
● Testing made easy -
issue the action, see
how your state changes
● Time travel
Summary
Building apps with a complex state can
be hard to develop and hard to debug
Redux can help you manage the app’s
state (and save you a lot of headaches)
Android can (and should) learn from
other platforms
More resources
Slides: http://shem8.github.io/talks/
Redux Docs: https://redux.js.org/
Dan Abramov’s talk: https://youtu.be/xsSnOQynTHs
Reductor: Redux implementation in Java: https://github.com/Yarikx/reductor
Bansa: Redux implementation in Kotlin: https://github.com/brianegan/bansa
Dan Abramov’s Redux tutorial: https://egghead.io/courses/getting-started-with-
redux
Join us!
limor.mekaiten
@gmail.com
smagnezi8
@gmail.com

Weitere ähnliche Inhalte

Ähnlich wie The Redux State of the Art

Ähnlich wie The Redux State of the Art (20)

Mobx Performance and Sanity
Mobx Performance and SanityMobx Performance and Sanity
Mobx Performance and Sanity
 
Simplified Android Development with Simple-Stack
Simplified Android Development with Simple-StackSimplified Android Development with Simple-Stack
Simplified Android Development with Simple-Stack
 
React state managmenet with Redux
React state managmenet with ReduxReact state managmenet with Redux
React state managmenet with Redux
 
From mvc to redux: 停看聽
From mvc to redux: 停看聽From mvc to redux: 停看聽
From mvc to redux: 停看聽
 
MVI - Managing State The Kotlin Way
MVI - Managing State The Kotlin WayMVI - Managing State The Kotlin Way
MVI - Managing State The Kotlin Way
 
Ngrx slides
Ngrx slidesNgrx slides
Ngrx slides
 
Kotlin Redux
Kotlin ReduxKotlin Redux
Kotlin Redux
 
Egghead redux-cheat-sheet-3-2-1
Egghead redux-cheat-sheet-3-2-1Egghead redux-cheat-sheet-3-2-1
Egghead redux-cheat-sheet-3-2-1
 
React + Redux. Best practices
React + Redux.  Best practicesReact + Redux.  Best practices
React + Redux. Best practices
 
Building Testable Reactive Apps with MVI
Building Testable Reactive Apps with MVIBuilding Testable Reactive Apps with MVI
Building Testable Reactive Apps with MVI
 
Android 3
Android 3Android 3
Android 3
 
Reactивная тяга
Reactивная тягаReactивная тяга
Reactивная тяга
 
What 100M downloads taught us about iOS architectures
What 100M downloads taught us about iOS architecturesWhat 100M downloads taught us about iOS architectures
What 100M downloads taught us about iOS architectures
 
Maintaining sanity in a large redux app
Maintaining sanity in a large redux appMaintaining sanity in a large redux app
Maintaining sanity in a large redux app
 
react-hooks.pdf
react-hooks.pdfreact-hooks.pdf
react-hooks.pdf
 
Android wearpp
Android wearppAndroid wearpp
Android wearpp
 
A Series of Fortunate Events - Symfony Camp Sweden 2014
A Series of Fortunate Events - Symfony Camp Sweden 2014A Series of Fortunate Events - Symfony Camp Sweden 2014
A Series of Fortunate Events - Symfony Camp Sweden 2014
 
React lecture
React lectureReact lecture
React lecture
 
Introduction to Redux
Introduction to ReduxIntroduction to Redux
Introduction to Redux
 
Android App Development - 05 Action bar
Android App Development - 05 Action barAndroid App Development - 05 Action bar
Android App Development - 05 Action bar
 

Mehr von Shem Magnezi

Mehr von Shem Magnezi (15)

The Future of Work(ers)
The Future of Work(ers)The Future of Work(ers)
The Future of Work(ers)
 
“Micro Frontends”- You Keep Using That Word, I Don’t Think It Means What You ...
“Micro Frontends”- You Keep Using That Word, I Don’t Think It Means What You ...“Micro Frontends”- You Keep Using That Word, I Don’t Think It Means What You ...
“Micro Frontends”- You Keep Using That Word, I Don’t Think It Means What You ...
 
Good rules for bad apps
Good rules for bad appsGood rules for bad apps
Good rules for bad apps
 
“Micro Frontends”- You Keep Using That Word, I Don’t Think It Means What You ...
“Micro Frontends”- You Keep Using That Word, I Don’t Think It Means What You ...“Micro Frontends”- You Keep Using That Word, I Don’t Think It Means What You ...
“Micro Frontends”- You Keep Using That Word, I Don’t Think It Means What You ...
 
Iterating on your idea
Iterating on your ideaIterating on your idea
Iterating on your idea
 
Startup hackers toolbox
Startup hackers toolboxStartup hackers toolbox
Startup hackers toolbox
 
Fuck you startup world
Fuck you startup worldFuck you startup world
Fuck you startup world
 
The Future of Work
The Future of WorkThe Future of Work
The Future of Work
 
Android Developer Toolbox 2017
Android Developer Toolbox 2017Android Developer Toolbox 2017
Android Developer Toolbox 2017
 
Good rules for bad apps
Good rules for bad appsGood rules for bad apps
Good rules for bad apps
 
Building android apps with kotlin
Building android apps with kotlinBuilding android apps with kotlin
Building android apps with kotlin
 
Andriod dev toolbox part 2
Andriod dev toolbox  part 2Andriod dev toolbox  part 2
Andriod dev toolbox part 2
 
Android dev toolbox
Android dev toolboxAndroid dev toolbox
Android dev toolbox
 
Know what (not) to build
Know what (not) to buildKnow what (not) to build
Know what (not) to build
 
Android ui tips & tricks
Android ui tips & tricksAndroid ui tips & tricks
Android ui tips & tricks
 

Kürzlich hochgeladen

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
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
shinachiaurasa2
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Kürzlich hochgeladen (20)

%+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...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%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
 
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
 
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
 
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
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
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
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
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
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%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
 
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
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
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
 

The Redux State of the Art

Hinweis der Redaktion

  1. Single source of truth - the state of your whole application is stored in an object tree within a single store The redux state lives high in the app and is shared between components, and all need Single SOT - store Easy to debug and inspect Some Undo/Redo actions suddenly become trivial to implement
  2. Single source of truth - the state of your whole application is stored in an object tree within a single store The redux state lives high in the app and is shared between components, and all need Single SOT - store Easy to debug and inspect Some Undo/Redo actions suddenly become trivial to implement
  3. Single source of truth - the state of your whole application is stored in an object tree within a single store The redux state lives high in the app and is shared between components, and all need Single SOT - store Easy to debug and inspect Some Undo/Redo actions suddenly become trivial to implement
  4. Single source of truth - the state of your whole application is stored in an object tree within a single store The redux state lives high in the app and is shared between components, and all need Single SOT - store Easy to debug and inspect Some Undo/Redo actions suddenly become trivial to implement