Slide 90
Slide 90 text
import { Action, createReducer, on } from '@ngrx/store';
import * as todoActions from './todo.actions';
const todoReducer = createReducer(
initialState,
on(todoActions.loadAllTodos,
(state) => ({
...state,
loading: true,
})
),
on(todoActions.loadAllTodosFinished,
(state, { payload }) => {
return {
...state,
loading: false,
items: [...payload],
};
}),
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
on(todoActions.loadAllTodosFinished,
(state, { payload }) => {
return {
...state,
loading: false,
items: [...payload],
};
}),
import { Action, createReducer, on } from '@ngrx/store';
1
import * as todoActions from './todo.actions';
2
3
const todoReducer = createReducer(
4
initialState,
5
on(todoActions.loadAllTodos,
6
(state) => ({
7
...state,
8
loading: true,
9
})
10
),
11
12
13
14
15
16
17
18
19
);
20