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

Post on 15-Apr-2017

415 views 0 download

Transcript of "Reducers in Action" Антон Молдован

Reducers in Action

Anton Moldovan EY

@antyadev

About me:

@AntyaDev like types*

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

Capture intent Easy to Scale

append only

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

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

(state, action) => state

Mutate its arguments

Perform side effects like API calls

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

Th

e P

ro

blem

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

@antyadev