我尝试在FirebaseListObservable上使用mergeMap时出现以下错误:
ERROR TypeError: chats.mergeMap is not a function
at MapSubscriber.project (tabs.ts:93)
at MapSubscriber._next (map.js:77)
at MapSubscriber.Subscriber.next (Subscriber.js:89)
at Notification.observe (Notification.js:32)
at QueueAction.ObserveOnSubscriber.dispatch (observeOn.js:50)
at QueueAction.AsyncAction._execute (AsyncAction.js:111)
at QueueAction.execute (QueueAction.js:33)
at QueueScheduler.AsyncScheduler.flush (AsyncScheduler.js:36)
at QueueAction.schedule (QueueAction.js:27)
at QueueScheduler.Scheduler.schedule (Scheduler.js:43)
这是我的组件代码:
this.msgService.getUserChatList()
.mergeMap( chats => chats.mergeMap( chat => {
return this.msgService.getLastMessage(chat.$key)
.map( lastMess => {
console.log('lastMess ', lastMess);
return this.containsUnreadMessages(lastMess, chat.lastPresence);
});
} )
)
.last()
.subscribe( (results) => {
console.log('finished ', results)
// Set global unread var
this.unread = this.anyUnread;
} );
返回FirebaseListObservable的getUserChatList函数:
getUserChatList(currentUserUid?: string): any {
let company = this.authService.getCurrentUserCompany();
let uid;
currentUserUid ? uid = currentUserUid : uid = this.authService.getCurrentUserUid();
let path = `/${company}/users/${uid}/chats`;
return this.af.list(path);
}
看起来我们必须双重包装FirebaseListObservable Github feature request
知道我为什么会收到这个错误吗?