node.js - EventEmitter 类型上不存在观察到的属性
问题描述
我们使用 angular (11.2.14) 并将 rxjs 库更新到 7.1.0。从那时起,我们在多个地方都有这个错误“属性'观察者'不存在于类型'EventEmitter'上”。根据我们发现的 PR(https://github.com/ReactiveX/rxjs/pull/6405#issue-645234112),应该观察到一个属性,但它不可用,因为我们使用的是 EventEmitter 而不是 Subject。
错误出现在构建上。
@Output() readonly onListCreate: EventEmitter<ListDto> = new EventEmitter(); // our emitter
createList() {
if (!this.newListName) {
return;
}
this.ListService.createList(this.newListName).subscribe((newList) => {
const newListViewModel: ListViewModel = {
id: newList.id,
name: this.newListName,
isAdded: false,
};
this.addModuleToList(newList, newListViewModel);
this.newListName = "";
if (this.onListCreate.observers.length === 0) { // error appears here
this.listsViewModel.push(newListViewModel);
this.ownedAndCoOwnedLists.push(newList);
}
this.onListCreate.emit(newList);
});
}
解决方案
推荐阅读
- node.js - 如何使用量角器阅读在新标签页中打开的 PDF 内容
- python - Django:如何从只有字段而不是 pk 和模型键的模型中获取 JSON 对象?
- r - 如何在因子变量的多个子集上循环线性回归
- scala - Akka HTTP 设置自定义内容类型响应标头
- mongodb - Mongo DB 比较两个数组并添加缺失的元素
- terraform - 使用环境变量时未找到 AWS Provider 的有效凭证源
- javascript - D3js:如何更新里面的孩子
使用画笔选择时? - c++ - 您如何使用 clang 的新自定义大小 int 功能?
- flutter - TabBarView 滑动事件监听器
- python - 如何添加所有这些质数?