Web Developer

Section 24 NgRx/effects

In order to deal with asynchronous responds, using ngrx side effects, install another package: npm install –save @ngrx/effects

Actions: is one big observable which will listen all dispatched actions, and imported from @ngrx/effects

ofType operator is unique for @ngrx/effects, which will filter actions and pass the actions observable (related to the ofType filter) to the next operator, normally is switchMap operator.

Finally, the Actions will return one action, which will be automatically dispatched by @ngrx/effects, so this will transfer data flow to reducers to finish the state update. At this time, you can use store.select() method, which is return observable, so you can listen it in ngOnInit to update data.