"reducers in action" Антон Молдован

29
Reducers in Action Anton Moldovan EY @antyadev

Upload: fwdays

Post on 15-Apr-2017

419 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: "Reducers in Action" Антон Молдован

Reducers in Action

Anton Moldovan EY

@antyadev

Page 2: "Reducers in Action" Антон Молдован

About me:

@AntyaDev like types*

Page 3: "Reducers in Action" Антон Молдован
Page 4: "Reducers in Action" Антон Молдован
Page 5: "Reducers in Action" Антон Молдован
Page 6: "Reducers in Action" Антон Молдован
Page 7: "Reducers in Action" Антон Молдован

Is an architectural pattern proposed by Greg Young that segregates reads and writes of system into two separate subsystems.

Page 8: "Reducers in Action" Антон Молдован
Page 9: "Reducers in Action" Антон Молдован

Capture intent Easy to Scale

Page 10: "Reducers in Action" Антон Молдован
Page 11: "Reducers in Action" Антон Молдован
Page 12: "Reducers in Action" Антон Молдован
Page 13: "Reducers in Action" Антон Молдован
Page 14: "Reducers in Action" Антон Молдован
Page 15: "Reducers in Action" Антон Молдован

append only

Page 16: "Reducers in Action" Антон Молдован
Page 17: "Reducers in Action" Антон Молдован
Page 18: "Reducers in Action" Антон Молдован
Page 19: "Reducers in Action" Антон Молдован
Page 20: "Reducers in Action" Антон Молдован
Page 21: "Reducers in Action" Антон Молдован
Page 22: "Reducers in Action" Антон Молдован
Page 23: "Reducers in Action" Антон Молдован
Page 24: "Reducers in Action" Антон Молдован

Reducer<I,E> :: (I, E) -> I

A pure function that takes an initial value and an element, and returns a new value for the initial item

Page 25: "Reducers in Action" Антон Молдован

const counter = (state, action) => { switch (action.type) { case 'INCREMENT': return state + 1; case 'DECREMENT': return state – 1; default: return state; } }

(state, action) => state

Page 26: "Reducers in Action" Антон Молдован

Mutate its arguments

Perform side effects like API calls

Calling non-pure functions like Date.now() or Math.random()

Page 27: "Reducers in Action" Антон Молдован

Th

e P

ro

blem

Page 28: "Reducers in Action" Антон Молдован

Greg Young • Event Sourcing https://www.youtube.com/watch?v=8JKjvY4etTY GregYoung 8 CQRS Class https://www.youtube.com/watch?v=whCk1Q87_ZI Timelines at Scale http://www.infoq.com/presentations/Twitter-Timeline-Scalability Redux http://redux.js.org/index.html

Page 29: "Reducers in Action" Антон Молдован

@antyadev