Эффекты ngrx не запускаются сразу, когда действие отправляется во второй раз - PullRequest
0 голосов
/ 01 мая 2020

Мой код работает следующим образом: при нажатии кнопки редактирования он перемещается из сводки на страницу ContactInfo, где находится моя отправка эффектов ngrx. После того, как вы щелкнете по следующей, она отправит вызов эффектов ngrx. PostData - это мой эффект ngrx при первом редактировании. Нажмите, эффект будет отправлен сразу, но не по щелчку во второй раз. когда-нибудь возникает проблема - мой API-интерфейс контролирует маршруты, которые мои маршруты будут генерировать с помощью API-ответа, поэтому в этом случае он переходит на неправильную страницу. переходит в ContactInfo

save(successpopup) {
this.spinner.show();
this.isNext = true;
this.isCurrentPage = true;
this.cpCommonService.clearErrorDivs();
if (this.router.url === '/byh/personalDetails/contactInfo') {
  this.navigationPath.componentName = 'contactInfo';
  let detailsObj = this.detailsContactInfoData(this.coverageData);
  this.store.dispatch(new TestActions.PostData(detailsObj));
  this.cpCommonService.clearErrorDivs();
    this.responseData$ = this.store.select('data').subscribe(resp => {
      this.isNextClicked = false;
      this.currentPageData = resp;
      if (resp['isAddClicked']) {
        this.isCurrentPage = false;
      }
      if (resp['isEditClicked']) {
        this.isCurrentPage = false;
      }
      if (resp['isBackClicked']) {
        this.isCurrentPage = false;
        this.store.dispatch(new TestActions.ResetBackClick());
      }
      if (resp['isEditAddressClicked']) {
        this.isCurrentPage = false;
        this.store.dispatch(new TestActions.ResetEditAddressClick());
      }
      if (Object.keys(resp['post']).length > 0 && this.isCurrentPage &&
      !resp['post'].serviceModel.app.hasOwnProperty('messages')) {
      if (resp['post'].serviceModel) {
        if (!this.isNextClicked) {
          if (Object.keys(resp['post']).length > 0) {
            if (!resp['post'].serviceModel.navState.haltNavigation) {
              this.spinner.hide();
              this.navigateAndSetModel(resp);
            }
            this.storeValuesAfterRefresh(resp);
          }
          this.isNextClicked = true;
        }
        this.isNext = false;
      }
    }
    });
} this.store.dispatch(new TestActions.UpdateMembersForm(this.currentPageData['personalForm']['value']));this.store.dispatch(new TestActions.PostDataSuccess(this.byhService.GetByhServiceModel()));}

Это мой следующий щелчок, когда эффект ngrx вызывается с использованием dispDat PostData, поэтому первый раз работает нормально, но во второй раз получает задержку, даже если эффект вызывается, но нет вызова на вкладке сети.

это мои эффекты выглядят как

    @Effect()
GetPostData$ = this.actions$.pipe(
    ofType<TestActions.PostData>(TestActions.POST_DATA),
    mergeMap(action =>
        this.byhService.navigationDetails(action.payload).pipe(map(resp => {
            console.log(resp);
            return new TestActions.PostDataSuccess(resp);
        }, catchError((error) => of(new TestActions.PostDataError(error))))
        )
    )
)
...