Skip to content

Commit

Permalink
Kill the term "reducing function"
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Nov 25, 2023
1 parent 3757120 commit 173ff78
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/api/Store.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The only way to change the state inside it is to dispatch an [action](../underst

A store is not a class. It's just an object with a few methods on it.

To create a store, pass your root [reducing function](../understanding/thinking-in-redux/Glossary.md#reducer) to Redux Toolkit's [`configureStore` method](https://redux-toolkit.js.org/api/configureStore), which will set up a Redux store with a good default configuration. (Alternately, if you're not yet using Redux Toolkit, you can use the original [`createStore`](createStore.md) method, but we encourage you to [migrate your code to use Redux Toolkit](../usage/migrating-to-modern-redux.mdx) as soon as possible)
To create a store, **pass your root [reducer function](../understanding/thinking-in-redux/Glossary.md#reducer) to Redux Toolkit's [`configureStore` method](https://redux-toolkit.js.org/api/configureStore)**, which will set up a Redux store with a good default configuration. (Alternately, if you're not yet using Redux Toolkit, you can use the original [`createStore`](createStore.md) method, but we encourage you to [migrate your code to use Redux Toolkit](../usage/migrating-to-modern-redux.mdx) as soon as possible)

## Store Methods

Expand All @@ -32,7 +32,7 @@ _(any)_: The current state tree of your application.

Dispatches an action. This is the only way to trigger a state change.

The store's reducing function will be called with the current [`getState()`](#getState) result and the given `action` synchronously. Its return value will be considered the next state. It will be returned from [`getState()`](#getState) from now on, and the change listeners will immediately be notified.
The store's reducer function will be called with the current [`getState()`](#getState) result and the given `action` synchronously. Its return value will be considered the next state. It will be returned from [`getState()`](#getState) from now on, and the change listeners will immediately be notified.

:::caution

Expand Down
4 changes: 2 additions & 2 deletions docs/api/combineReducers.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ You can control state key names by using different keys for the reducers in the

## Arguments

1. `reducers` (_Object_): An object whose values correspond to different reducing functions that need to be combined into one.
1. `reducers` (_Object_): An object whose values correspond to different reducer functions that need to be combined into one.

```ts
combineReducers({
Expand Down Expand Up @@ -153,6 +153,6 @@ console.log(store.getState())

## Tips

- This helper is just a convenience! You can write your own `combineReducers` that [works differently](https://github.com/redux-utilities/reduce-reducers), or even assemble the state object from the child reducers manually and write a root reducing function explicitly, like you would write any other function.
- This helper is just a convenience! You can write your own `combineReducers` that [works differently](https://github.com/redux-utilities/reduce-reducers), or even assemble the state object from the child reducers manually and write a root reducer function explicitly, like you would write any other function.

- You may call `combineReducers` at any level of the reducer hierarchy. It doesn't have to happen at the top. In fact you may use it again to split the child reducers that get too complicated into independent grandchildren, and so on.
2 changes: 1 addition & 1 deletion docs/api/createStore.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ See the [**Migrating to Modern Redux** page](../usage/migrating-to-modern-redux.

## Arguments

1. `reducer` _(Function)_: A [reducing function](../understanding/thinking-in-redux/Glossary.md#reducer) that returns the next [state tree](../understanding/thinking-in-redux/Glossary.md#state), given the current state tree and an [action](../understanding/thinking-in-redux/Glossary.md#action) to handle.
1. `reducer` _(Function)_: A root [reducer function](../understanding/thinking-in-redux/Glossary.md#reducer) that returns the next [state tree](../understanding/thinking-in-redux/Glossary.md#state), given the current state tree and an [action](../understanding/thinking-in-redux/Glossary.md#action) to handle.

2. [`preloadedState`] _(any)_: The initial state. You may optionally specify it to hydrate the state from the server in universal apps, or to restore a previously serialized user session. If you produced `reducer` with [`combineReducers`](combineReducers.md), this must be a plain object with the same shape as the keys passed to it. Otherwise, you are free to pass anything that your `reducer` can understand.

Expand Down
2 changes: 1 addition & 1 deletion docs/introduction/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ store.dispatch(decremented())

Instead of mutating the state directly, you specify the mutations you want to happen with plain objects called _actions_. Then you write a special function called a _reducer_ to decide how every action transforms the entire application's state.

In a typical Redux app, there is just a single store with a single root reducing function. As your app grows, you split the root reducer into smaller reducers independently operating on the different parts of the state tree. This is exactly like how there is just one root component in a React app, but it is composed out of many small components.
In a typical Redux app, there is just a single store with a single root reducer function. As your app grows, you split the root reducer into smaller reducers independently operating on the different parts of the state tree. This is exactly like how there is just one root component in a React app, but it is composed out of many small components.

This architecture might seem like a lot for a counter app, but the beauty of this pattern is how well it scales to large and complex apps. It also enables very powerful developer tools, because it is possible to trace every mutation to the action that caused it. You can record user sessions and reproduce them just by replaying every action.

Expand Down
2 changes: 1 addition & 1 deletion docs/understanding/thinking-in-redux/Glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ See also [async action](#async-action) below.
type Reducer<S, A> = (state: S, action: A) => S
```

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.
A _reducer_ 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.

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()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce).

Expand Down
2 changes: 1 addition & 1 deletion docs/usage/ReducingBoilerplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ AppDispatcher.register(function (action) {
export default TodoStore
```

With Redux, the same update logic can be described as a reducing function:
With Redux, the same update logic can be described as a reducer function:

```js
export function todos(state = [], action) {
Expand Down

0 comments on commit 173ff78

Please sign in to comment.