ngrx效果在第一次点击时未从api获取数据

问题描述 投票:0回答:1

您好,下面是我的组件代码,其中保存函数具有validateData(),该函数已调用api,并且在store.select中的调用被调用之后,但在第一次命中时未获得响应,而在第二次命中时获得了更新,而对Navigationtonext()进行了更新。函数接受响应,因此如果第一次在存储区中写入nagigatetonext函数,则会第二次点击它以获取空对象。多次选择被调用。

    save(){
    this.cpCommonService.clearErrorDivs();
 // this.spinner.show();
    if(this.router.url === '/test/details'){
       this.ethnicityData();
    }else if(this.router.url === '/test/details/member_name'){
      this.navigationPath.componentName = "member_name";
      this.validateData();
    }else{
      // this.navigationPath.componentName = "member_ssn";
      this.ssnData();
    }


    this.store.select('data').subscribe(data => {
      this.currentPageData = data;
      this.isNextClicked = false;

    });
     this.nextPage(this.currentPageData);
    this.store.dispatch(new TestActions.UpdateMembersForm(this.currentPageData['membersForm']['value']));
  }

    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))))
        )

    )
)
angular ngrx ngrx-effects angular-ngrx-data
1个回答
0
投票
[GetPostData$未被@Effect或createEffect标记为效果。

动作将不会分派。

© www.soinside.com 2019 - 2024. All rights reserved.