Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular NgRx8从操作中销毁值_Angular_Typescript_Rxjs_Ngrx - Fatal编程技术网

Angular NgRx8从操作中销毁值

Angular NgRx8从操作中销毁值,angular,typescript,rxjs,ngrx,Angular,Typescript,Rxjs,Ngrx,各位,我想销毁ngrx效果中的动作类型和道具,我一直在思考如何才能做到这一点 我的行动: export const addTab = createAction( '[SuperUserTabs] add tab', props<{ tab: SuperUserHeaderTab, tabType: TabType }>() ); export const searchCompanyTab = createAction( '[SuperUserTabs] search c

各位,我想销毁ngrx效果中的动作类型和道具,我一直在思考如何才能做到这一点

我的行动:

export const addTab = createAction(
  '[SuperUserTabs] add tab',
  props<{ tab: SuperUserHeaderTab, tabType: TabType }>()
);

export const searchCompanyTab = createAction(
  '[SuperUserTabs] search company tab'
);

export const searchCardholderTab = createAction(
  '[SuperUserTabs] search cardholder tab'
);

有什么建议吗

更新了
类型
接受操作创建者,因此您可以直接使用它:

@Effect({ dispatch: false })
  addTab$ = this.actions$.pipe(
    ofType(
      TabsActions.addTab,
      TabsActions.searchCompanyTab,
      TabsActions.searchCardholderTab
    ),
    withLatestFrom(this.store.pipe(select(getTabs))),
    tap(([action, tabs]) => {
      // this object will contain `type` and action payload
      const {type, ...payload} = action; 
      // some logic
      console.log(payload)
    })
  );
============== 旧答案同样有效:

因为您使用的是action creator,它返回一个函数,所以您可以通过
type
属性访问action类型,如下所示:

@Effect({ dispatch: false })
  addTab$ = this.actions$.pipe(
    ofType(
      TabsActions.addTab.type,
      TabsActions.searchCompanyTab.type,
      TabsActions.searchCardholderTab.type
    ),
    withLatestFrom(this.store.pipe(select(getTabs))),
    tap(([action, tabs]) => {
      // this object will contain `type` and action payload
      const {type, ...payload} = action; 
      // some logic
      console.log(payload)
    })
  );

演示:

更新了类型为的accept action creator,因此您可以直接使用它:

@Effect({ dispatch: false })
  addTab$ = this.actions$.pipe(
    ofType(
      TabsActions.addTab,
      TabsActions.searchCompanyTab,
      TabsActions.searchCardholderTab
    ),
    withLatestFrom(this.store.pipe(select(getTabs))),
    tap(([action, tabs]) => {
      // this object will contain `type` and action payload
      const {type, ...payload} = action; 
      // some logic
      console.log(payload)
    })
  );
============== 旧答案同样有效:

因为您使用的是action creator,它返回一个函数,所以您可以通过
type
属性访问action类型,如下所示:

@Effect({ dispatch: false })
  addTab$ = this.actions$.pipe(
    ofType(
      TabsActions.addTab.type,
      TabsActions.searchCompanyTab.type,
      TabsActions.searchCardholderTab.type
    ),
    withLatestFrom(this.store.pipe(select(getTabs))),
    tap(([action, tabs]) => {
      // this object will contain `type` and action payload
      const {type, ...payload} = action; 
      // some logic
      console.log(payload)
    })
  );

演示:

你的意思是发射一个
destruct
动作或“摧毁一个动作”(不管那意味着什么)?你的意思是发射一个
destruct
动作或“摧毁一个动作”(不管那意味着什么)?