首页 > Web开发 > 详细

rxjs switchmap 应用案例

时间:2021-06-26 17:02:33      阅读:17      评论:0      收藏:0      [点我收藏+]
loadTree() {
this.auditItemTypeService
.findAllTree()
.pipe(
switchMap((result: Array<TreeDto>) => {
this.nodes = result;
if (result && result.length) {
// this.activeNode = this.nodes.find(item => {
// return item.key === this.activeNode.key;
// });
this.activeNode = this.findNode(this.nodes, this.currentItemId);
if (!this.activeNode) {
this.activeNode = this.nodes[0];
}
if (this.activeNode) {
this.activeNode.selected = true;
this.expandedKeys = [this.activeNode.key];
}
return this.auditItemTypeService.findById(this.activeNode.key);
} else {
this.activeNode = null;
return of(null);
}
}),
)
.subscribe(res => {
if (res) {
this.isLeaf = false;
this.auditItemTypeDetailComponent.edit(res);
this.isEdit = false;
}
});
}

rxjs switchmap 应用案例

原文:https://www.cnblogs.com/modestlin/p/14934383.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!