【发布时间】:2021-03-05 19:43:12
【问题描述】:
在下面的代码中,我在订阅中使用了订阅。此代码有效,但代码结构非常糟糕。我想使用 rxjs(forkjoin 或 mergemap)重构此代码。我不知道如何实现这一点。有人可以帮我弄这个吗?任何帮助表示赞赏。
this.chapservice.cycle().subscribe((current) => {
this.selectedCycleId = current.ratingCycleId;
this.chapService
.getChapterEvalWithSkills(
this.activeUser.ipn,
this.selectedRatingCycleId
)
.subscribe((response) => {
console.log("response", response);
if (response && response.length > 0) {
this.chapterEvals = response;
}
});
this.chapservice
.getIsitEmployeeStatus(this.activeUser.ipn, this.selectedCycleId)
.subscribe((sdpStatus) => {
this.activeUserStatus = sdpStatus;
if (this.activeUserStatus.statusDescription == 'SUBMITTED') {
//do something
}
});
});
【问题讨论】:
-
内部订阅你希望它是全职订阅还是只执行一次
-
需要全职执行
标签: angular typescript rxjs-observables