Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions projects/ngrx.io/content/guide/entity/adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ export const initialState: State = adapter.getInitialState({
selectedUserId: null,
});

const userReducer = createReducer(initialState);

export function reducer(state: State | undefined, action: Action) {
return userReducer(state, action);
}
export const userReducer = createReducer(initialState);
</code-example>

## Adapter Collection Methods
Expand Down Expand Up @@ -149,7 +145,7 @@ export const initialState: State = adapter.getInitialState({
selectedUserId: null,
});

const userReducer = createReducer(
export const userReducer = createReducer(
initialState,
on(UserActions.addUser, (state, { user }) => {
return adapter.addOne(user, state)
Expand Down Expand Up @@ -198,9 +194,6 @@ const userReducer = createReducer(
})
);

export function reducer(state: State | undefined, action: Action) {
return userReducer(state, action);
}

export const getSelectedUserId = (state: State) => state.selectedUserId;

Expand Down
5 changes: 1 addition & 4 deletions projects/ngrx.io/content/guide/store/reducers.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,14 @@ The initial values for the `home` and `away` properties of the state are 0.
The reducer function's responsibility is to handle the state transitions in an immutable way. Create a reducer function that handles the actions for managing the state of the scoreboard using the `createReducer` function.

<code-example header="scoreboard.reducer.ts">
const scoreboardReducer = createReducer(
export const scoreboardReducer = createReducer(
initialState,
on(ScoreboardPageActions.homeScore, state => ({ ...state, home: state.home + 1 })),
on(ScoreboardPageActions.awayScore, state => ({ ...state, away: state.away + 1 })),
on(ScoreboardPageActions.resetScore, state => ({ home: 0, away: 0 })),
on(ScoreboardPageActions.setScores, (state, { game }) => ({ home: game.home, away: game.away }))
);

export function reducer(state: State | undefined, action: Action) {
return scoreboardReducer(state, action);
}
</code-example>

<div class="alert is-important">
Expand Down