Put a knob on that Redux Store
State is like a film reel
Set the right fps
State is like a film reel
Set the right fps
todos: [
{
text: βMake slidesβ
completed: false
},
{
text: βPracticeβ
Completed: false
}
todos: [
{
text: βMake slidesβ
completed: true
},
{
text: βPracticeβ
Completed: false
}
todos: [
{
text: βMake slidesβ
completed: true
},
{
text: βPracticeβ
Completed: true
}
slidesPrepared()
practiced()
Quite Literally
Redux in Motion
Middleware
Reducer
Store
View
Action 1
API
Action 2
Action 3
Middleware
Reducer
Store
View
Action 2
Action 3
render(1)
Redux in Motion
Redux in Motion
Middleware
Reducer
Store
View
Action 3
render(2)
Redux in Motion
Middleware
Reducer
Store
View
render(3)
dispatch(showSidePanel())
β¦
dispatch(updateProgress({ percent : 85 }));
β¦
dispatch(hideMenu());
...
Looks familiar?
dispatch(showSidePanel())
β¦
dispatch(updateProgress({ percent : 85 }));
β¦
dispatch(hideMenu());
...
Looks familiar?
for( β¦ ) {
dispatch(selectRow( {id: index} ))
}
Looks innocent.
Middleware
Reducer
Store
View
Action
API
Action
Action
Action
Action
Action
Action
Action
Action
Action
Action
Action
Action
Middleware
Reducer
Store
View
Action
API
Action
Action
Action
Action
Action
Action
Action
Action
Action
Action
Action
Action
Seriously?
render()
render()
render()
render()
render()
render()
render()
render()
render()
Problem
I am impatient & I have a hack for this π
Breakfast Buffet
redux-knob
π·ββοΈ The Redux middleware toolbelt
β¦
dispatch(batchedAction([
showSidePanel(),
updateStats({ progress: 85 }),
hideMenu(),
]))
Redux in Motion
redux-knob
Reducer
Store
View
Action 3
Action 2
Action 1
Batched Action
Action 5
Action 4
Batched Action
Redux in Motion
redux-knob
Reducer
Store
View
Action 5
Action 4
Batched Action
render(1 , 2, 3)
newState = action3(action2(action1(reducer)))
Redux in Motion
redux-knob
Reducer
Store
View
render(4, 5)
newState = action5(action4(reducer))
But wait, there is more
Action Queues
Redux in Motion
redux-knob
Reducer
Store
View
Enable Queue
Action 1
Action 2
Action Queue
Redux in Motion
redux-knob
Reducer
Store
View
Action 1
Action 2
Action Queue
Flush Queue
Redux in Motion
redux-knob
Reducer
Store
View
Action 2
Flush Queue
Action Queue
Action 1
Redux in Motion
redux-knob
Reducer
Store
View
Flush Queue
Action Queue
Action 1
Action 2
Redux in Motion
redux-knob
Reducer
Store
View
Action Queue
Action 1
Action 2
Redux in Motion
redux-knob
Reducer
Store
View
Action 2
Action 1
Batched Action
Action Queue
Redux in Motion
redux-knob
Reducer
Store
View
render(1, 2)
Action Queue
newState = action2(action1(reducer))
Tip 1
Donβt make a long wait. Never.
Tip 2
You can have Queue Jumpers
Tip 3
Fine tune with care based on
Tip 4
Throttle actions (Not all)
Yes, we can have policy based ActionQueues !
So yeah, that's the end
@TheWizardJS π§ββοΈ
(Thiyagaraj T)
I work for an awesome company
Kubric.io
Thatβs all Folks