我有一个相对简单的情况,我只想根据条件选择和分配2个选择/分配中的一个。
非条件代码:
this.store.pipe(
select(fromChallengesSelectors.getSelectedMyChallenge),
tap((challenge: Challenge) => {
if (!challenge) {
this.store.dispatch(new fromChallengesActions.SelectMyChallengeAction(this.challengeId));
}
}),
filter((challenge: Challenge) => !!challenge),
// .....
);
现在我想做任何一个
select(fromChallengesSelectors.getSelectedMyChallenge)
+ this.store.dispatch(new fromChallengesActions.SelectMyChallengeAction (this.challengeId))
或
select(fromChallengesSelectors.getSelectedNetworkChallenge)
+ this.store.dispatch(new fromChallengesActions .SelectNetworkChallengeAction (this.challengeId))
根据this.route.data.profil
的值,其余代码将保持不变
例如可以使用iff
运算符来做到这一点吗?