可以影响像Promise.all这样的两个动作吗?例:
@Effect()
pulic addUser() {
return this.actions$.ofType(user.ADD)
.switchMap(() => {
return this.userService.add();
})
.map(() => {
return new user.AddSuccessAction();
});
}
@Effect()
pulic addUserOptions() {
return this.actions$.ofType(userOptions.ADD)
.switchMap(() => {
return this.userOptionsService.add();
})
.map(() => {
return new userOptions.AddSuccessAction();
});
}
@Effect()
public complete() {
return this.actions$.ofType(user.ADD_SUCCESS, userOptions.ADD_SUCCESS)
// how to make it works like Promise.all ?
.switchMap(() => {
return this.statisticService.add();
})
.map(() => {
return new account.CompleteAction();
});
}
Run Code Online (Sandbox Code Playgroud)
更新 我想要实现的是Promise.all的simillar行为.如何并行调度两个效果,等待所有效果都解决,然后发出第三个动作.像https://redux-saga.js.org/docs/advanced/RunningTasksInParallel.html这样的承诺它是非常明显的:
Promise.all([fetch1, fetch2]).then(fetch3);
Run Code Online (Sandbox Code Playgroud)
是否有可能在ngrx /效果?或者在ngrx /效果中它是错误的方式? …
我想动态创建一个URL树,并在Angular的路由器中使用它而不是"魔术"字符串.我有这些课程:
export abstract class UrlNode {
protected parentUrl?: string;
protected abstract shortUrl: string;
constructor(parent: UrlNode) {
this.parentUrl = parent && parent.path;
}
public get segmentUrl(): string {
return this.shortUrl;
}
public get path(): string {
if (!this.parentUrl) {
return this.shortUrl;
}
if (!this.shortUrl) {
return this.parentUrl;
}
return `${this.parentUrl}/${this.shortUrl}`;
}
}
export class Profile extends UrlNode {
protected shortUrl = "profile";
}
export class User extends UrlNode {
public readonly profile: Profile;
public readonly someSubroute: SomeSubroute;
protected shortUrl = "user"; …Run Code Online (Sandbox Code Playgroud)