The effect – listening to a specific dispatched action

So we come to the effect. Our effect acts like a listener to a dispatched action. This gives us the opportunity to carry out a unit of work, but also to dispatch an action once that work is done. 

We have created all the usual bits that we are used to, so now it is time to create our effect that will handle the entire workflow:

// product/product.effect.tsimport { Actions, Effect } from "@ngrx/effects";@Injectable()export class ProductEffects {  @Effect() products$: Observable<Action>;  constructor(    private actions$: Actions<Action>>  ) {}}

The effect is just a class decorated with the @Injectable decorator. It also contains two members: one member of Actions type and another of the Observable<Action> ...

Get Architecting Angular Applications with Redux, RxJS, and NgRx now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.