Get params from typeOf ngrx effects

Published

I have something like this

  ngOnInit() {
   this.store.dispatch(new TutorialActions.GetTutorials(1,20));
  }

export class GetTutorials implements Action {
  readonly type = GET_TUTORIALS
  constructor(public number: number, public offset: number) { }
}

And then i have effects like this

export class TutorialEffects {
  loadTutorials$ = createEffect(() =>
    this.action$.pipe(
      ofType(TutorialActions.GET_TUTORIALS),
      switchMap(() =>
        this.tutorialService.getAll(0,20).pipe(
          map((tutorial: Tutorial[]) => new TutorialActions.SuccesGetTutorials(tutorial)),
          catchError((error) => of(error))
        )
      )
    )
  );

}

The problem is in ofType(TutorialActions.GET_TUTORIALS), this.tutorialService.getAll(0,20)
That value should be passed from ngOnInit functions and can be dynamic?

Source: Angular Questions

Published
Categorized as angular, ngrx, observable, rxjs Tagged , , ,

Answers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq