您可以創建一個轉換器
const mapToFirebaseListObservable = (source) => {
new FirebaseListObservable(observer => {
return source.subscribe({
next(x) { observer.next(x); },
error(err) { observer.error(err); },
complete() { observer.complete(); }
})
})
}
與
var firebaseList = mapToFirebaseListObservable(
loggedInUserId
.flatMap((userId) => this.db.list(this.firebaseRoot.child(userId)))
)
我還沒有嘗試過了一個完整的火力點安裝,使用它,所以你可能會得到一個錯誤newing了FirebaseListObservable,但我已經使用具有附加功能的Observable嘗試過它
const newObservable = new Observable(observer => {
...
})
newObservable['myFn'] =() => 'from myFn'
並且該函數在輸出中存在且可調用。
編輯:這似乎也工作
const toInner = (source) => {
return source.operator && source.operator.project
? source.operator.project()
: source
}
用法:
var firebaseList = toInner(
loggedInUserId
.flatMap((userId) => this.db.list(this.firebaseRoot.child(userId)))
)
它也可以變成一個連鎖運營商
const toInner = function() {
const source = this
return source.operator && source.operator.project
? source.operator.project()
: source
}
Observable.prototype.toInner = toInner;
又見here爲Rxjs v5.50beta關於創建操作符的更改。
這是不可能的。在[this]中看到我的評論(https://github.com/angular/angularfire2/issues/1008#issuecomment-304510732)AngularFire2問題的解釋。請隨時修改您的問題和[自我回復](https://stackoverflow.com/help/self-answer)。 – cartant