首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何连锁采购

如何连锁采购
EN

Stack Overflow用户
提问于 2019-04-09 09:18:23
回答 1查看 76关注 0票数 0

嗨,我正在尝试连锁跟踪订阅。

代码语言:javascript
复制
  changeBranch() {
const bottomSheetRef: MatBottomSheetRef = this.bottomSheet.open(CCSBranchComponent, {
  data: this.branches
});
this.subscription.add(bottomSheetRef.instance.change.subscribe((branch: Branch) => {
  this.branchInfo = `Description : ${branch.author}\nAuthor : ${branch.id}\nCreated date :${branch.created}`;
  this.blockpointBranchForm.get('branch').setValue(branch.id);
}));
this.subscription.add(bottomSheetRef.afterDismissed().subscribe(() => {
this.returnSelectedBranch.emit(this.blockpointBranchForm.get('branch').value);
}));

}

在这里,如果在加载表之前调用了bottomSheetRef.instance.change.subscribe,那么它会抛出未定义的。所以我正在尝试像这样的工具

代码语言:javascript
复制
this.subscription.add(this.bottomSheet.open(CCSBranchComponent, {
  data: this.branches
}).instance.change.subscribe((branch: Branch) => {
  this.branchInfo = `Description : ${branch.author}\nAuthor : ${branch.id}\nCreated date :${branch.created}`;
  this.blockpointBranchForm.get('branch').setValue(branch.id);
}).afterDismissed().subscribe(() => {
this.returnSelectedBranch.emit(this.blockpointBranchForm.get('branch').value);
}));

在这里,第二个订阅首先对订阅返回进行调用。如何访问链中可观察到的信息?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-04 09:06:12

我想你想要的是把订阅时所做的动作链锁起来。

你可以通过

代码语言:javascript
复制
bottemsheetRef.instance.change.pipe(
 switchmap(resultFromChange => bottomSheetRef.afterDismissed
).subsbribe(resultFromAfterDismissed => {// do whatever you like})
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55589256

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档