【发布时间】:2018-04-24 03:43:42
【问题描述】:
我正在将 ionic 3.8 应用程序迁移到 3.9.2。 此迁移包括对 RXJS 5.5 的更新
我现在遇到了这个错误:
TypeError: this._subscribe is not a function. (In 'this._subscribe(sink)', 'this._subscribe' is an instance of t)
经过几个小时的调试,我发现这部分代码与错误有关:
protected observeConnectionState() {
// rxjs/observable/of
of(new Event('disconnect'))
.pipe(
// rxjs/operators/merge
merge(connect$),
merge(disconnect$),
// Map eventname to string (rxjs/operators/map)
map((e: IEvent) => {
return e.eventName == 'connect' ? 'connected' : 'disconnected';
})
)
// Apply to class context
.subscribe((newConnectionState) => {
// this.connectionState$ is a BehaviorSubject
this.connectionState$.next(newConnectionState);
});
}
附加信息
- RXJS 代码中有两个地方,我能找到
this._subscribe:Observable.ts Line 203 和Observable.ts Line 208。
【问题讨论】:
-
你能创建一个minimal reproducible example,任何人都可以运行而不必尝试存根各种变量/字段(如connect$、disconnect$等)吗?一旦你有了,我建议你在rxjs project 网站上发布。
-
我已经在努力了。但由于该错误仅与 Cordova 相关,因此我希望这些人指向 Cordova。科尔多瓦会指向他们等等。
-
是的,这可能会发生:/。拥有minimal reproducible example 后,您唯一可以做的另一件事是复制整个堆栈跟踪并包含要包含的错误消息。