Review of Reducers and Pure Functions

One of the core concepts of Redux is the reducer. A reducer is a function withthe signature (accumulator: T, item: U) => T. Reducers are often used in JavaScript through the Array.reduce method, which iterates over each of the array's items and accumulates a single value as a result. Reducers should be pure functions, meaning they don't generate any side-effects.

A simple example of a reducer is the sum function:

  1. let x = [1, 2, 3].reduce((sum, number) => sum + number, 0);
  2. // x == 6

原文: https://angular-2-training-book.rangle.io/handout/state-management/ngrx/reducers_and_pure_functions.html