as a single Object (State) 2. You can update State only by dispatching Action, or rather a new State is created 3. State is updated by pure func)ons called Reducer, which always returns the same result for each set of arguments reducer : (State, Action) -> State
component: We want to keep components as simple as possible • Do in Ac<on Creator: You have to pass dispatch only to effecBul ac<on creators, which is kind of inconsistent
You can receive an Action and do something with it: • Delay Action • Replace an Action to another one • Do asynchronous thing and dispatch the result as an Action • e.g. WSGI, Rack, Express, Koa, etc.
| ---- | --------- | ---- | ---- | ---- | ---- | | name | star | from | test | time | cohe | acti | | ----------------- | ---- | --------- | ---- | ---- | ---- | ---- | | redux-thunk | 2392 | '15/07/13 | C | C | B | A | | redux-promise | 864 | '15/07/02 | - | C | C | C | | redux-saga | 3172 | '15/11/30 | B | A | A | A | | redux-loop | 641 | '16/01/06 | A | C | B | C | | redux-observable | 634 | '16/02/16 | C | A | B | A | | ----------------- | ---- | --------- | ---- | ---- | ---- | ---- | The numbers of ⭐ were recorded on June 5th, 2016
Hard to do debouncing because it takes ac2ons one by one • # Able to describe complex logic • ✨ Well maintained (actually only 13 lines of code!) • Reference: How to dispatch a Redux ac2on with a 2meout?
Standard Ac7on and dispatches the result function fetchItems() { const promise = fetch('/items').then(res => res.json()); return { type: 'FETCH_ITEMS', payload: promise }; } dispatch(fetchItems());
Can't do debouncing and etc. • # Too simple for complex logic • ✨ No commit in the last 4 months (only 25 lines of code though...) • A seemingly important MR for error handling has been merged but not released
side effect requests, has the middleware to execute them, and receives the response • Able to describe complex asynchronous opera=ons while keeping them pure • See the upcoming talk by @kuy
Effects in addi4on to state function beers(state = [], action) { switch (action.type) { case 'FETCH_BEERS': return loop(state, Effects.promise(fetchBeers)); case 'FETCH_BEERS_SUCCEEDED': return action.payload; default: return state; } }
are plain Objects. Side effects won't happen un-l executed • " hard to do debouncing and etc. • # Composable Effects • ✨ Not maintained for 3 months. The author has completely moved to the Elm world?
• " Able to control 4me by Rx's powerful operators • # Progressed into background processor style like redux-saga • Able to express complex procedure • ✨ Being ac4vely developed and super simple source code • Rx is fun to use!