Method next() on ReplaySubject not working in subscribe

568 Views Asked by At

I have a that code:

enum URLs {
  'STORY_BUILDER' = 'story-builder',
  'IB_VIEW' = 'ib-view',
}

defaultGroupStoryRequest$ = new ReplaySubject<boolean>();
defaultGroupIbViewRequest$ = new ReplaySubject<boolean>();



const invalidRequest = R.pathOr(
  false,
  ['extras', 'state', 'invalidRequest'],
  navigation,
);

if (invalidRequest) {
  this.router.events
    .pipe(
      filter((e) => e instanceof NavigationEnd),
      pairwise(),
    )
    .subscribe((e) => {
      const parts = (e[0] as NavigationEnd).url.split('/');
      const previousPage = parts[parts.length - 1];
      this.defaultGroupIbViewRequest$.next(previousPage === URLs.IB_VIEW);
      this.defaultGroupStoryRequest$.next(previousPage === URLs.STORY_BUILDER);
    });
}

And in template:

<shared-overlay [isVisible]="defaultGroupStoryRequest$ | async">
<ng-template>
<shared-confirm
  type="warning"
  question="Generating Story for the default group is not allowed."
  label="Please select different group."
  acceptText="Ok"
  acceptButtonStyle="btn-danger-outline"
  [showDeclineButton]="false"
  (accept)="defaultGroupStoryRequest$.next(false)"
>
</shared-confirm>

Subscribe is executing but i can't send value using next() method to show popup. Why my next() method don't execute? I want get previous page, and compare with value from enum, and after display popup on the screen.

0

There are 0 best solutions below