0

Component logic

this.actions$
    .pipe(
       ofActionSuccessful(ProjectLoad),
       switchMap(() => interval(10000))
      )
      .subscribe(() => this.store.dispatch(new ProjecRefresh));

I'd like to test that ProjecRefresh is dispatched after dispatching ProjectLoad and I don't have any idea of how to do it

Donovant
  • 3,091
  • 8
  • 40
  • 68

1 Answers1

0

It seems to me that dispatching ProjectLoad should be a part of the state logic instead of a component: potential multiple consumers and complex refresh logic may force this sooner.

Then the component code transforms into something like


...
ngOnInit() {
    this.store.dispatch(new ProjectAutoRefreshEnabled())
}

...

ngOnDestroy() {
    // state logic may actually track consumers when this is handled
    // and decide to keep refreshing for other purposes
    // so this is something that shouldn't be in a component IMHO
    this.store.dispatch(new ProjectAutoRefreshDisabled())
}

Ivan Kashtanov
  • 674
  • 4
  • 17