From the course: Learning NgRx

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Implementation of effects

Implementation of effects - Angular Tutorial

From the course: Learning NgRx

Start my 1-month free trial

Implementation of effects

- [Instructor] I'm going to the effects folder and opening the effects.ts file. That's what an effect looks like. So at first this seems to be a little bit verbal. It's a lot of code in here. An effect works like this. I'm going to go through this file line-by-line. On line 13, we use a decorator @Effect() to mark that this is going to be where an effect comes into play. This tells NgRx that it has to do some work here in order to notify whenever such action gets dispatched. What we do on line number 14, is the next step, we get access to actions, which is a service from NgRx. Basically, any action dispatched to the store will go through that action's observable. We're gonna pipe some custom work to that observable. The first thing we do on line 15, is filter. So we're gonna filter all of the actions because we are only interested in the ones that are ofType AddZipCode. Whenever we add a zipcode to our weather app, we want to send a request to get the weather conditions for that…

Contents