Redux Reducer 超適当訳
Reducer
A reducer (also called a reducing function) is a function that accepts an accumulation and a value and returns a new accumulation. They are used to reduce a collection of values down to a single value.
reducer とは 関数である。accumulationとvalueを受け取って、新しいaccumulationを返すものである。
valueの集合を一つのvalueにすることを手掛ける。
Reducers are not unique to Redux—they are a fundamental concept in functional programming. Even most non-functional languages, like JavaScript, have a built-in API for reducing. In JavaScript, it's Array.prototype.reduce().
Reducersは関数型プログラミングの基礎概念でありRedux特有のものではない。
In Redux, the accumulated value is the state object, and the values being accumulated are actions. Reducers calculate a new state given the previous state and an action. They must be pure functions—functions that return the exact same output for given inputs. They should also be free of side-effects. This is what enables exciting features like hot reloading and time travel. Reducers are the most important concept in Redux. Do not put API calls into reducers.
Reduxにおいて accumulated value は state オブジェクトであり、 accumulate された値はアクションです。 Reducerは以前のstateを受けて新しいstateを返す純粋関数のアクションです。(純粋関数とはインプットが同じであれば必ず同じアウトプットを返す関数のこと) 副作用がなくホットリローディングやタイムトラベルのような特徴がある。 Reducers は Reduxにおいて最も重要な概念である。
APIを呼び出すようなコードをreducersに入れてはならない。
入門 React ―コンポーネントベースのWebフロントエンド開発
- 作者: Frankie Bagnardi,Jonathan Beebe,Richard Feldman,Tom Hallett,Simon HØjberg,Karl Mikkelsen,宮崎空
- 出版社/メーカー: オライリージャパン
- 発売日: 2015/04/03
- メディア: 大型本
- この商品を含むブログ (2件) を見る