13. Add simple NgRx spinner
In this section we will introduce redux and start converting our demo application to an NgRx powered application. We will skip strong typing and action creators till the next section.
1. npm i NgRx Store library
npm i @ngrx/store2. Add a reducer
export function reducer(state = { isOn: false }, action) {
switch (action.type) {
case 'startSpinner': {
return {
isOn: true
};
}
case 'stopSpinner': {
return {
isOn: false
};
}
default:
return state;
}
}
3. Register NgRx in app module
4. Inject store into the EventComponent
5. Dispatch an action when adding new attendees
6. Update the EventComponent to show a basic loading indicator

StackBlitz Link
Last updated