我有一个从 angularfire 检索到的引用数组
this.userIds$ = this.users$.switchMap(email =>
db.list('/USERS/', ref => {
let temp = email ? ref.orderByChild('EMAIL').startAt(email).endAt(email + "\uf8ff") : ref
console.log('carrot');
return temp;
}
).snapshotChanges()
);
我试图将这些数据作为一个可观察的数据返回,但是虽然我可以看到填充正确数据库引用的路径,但什么时候说完我的配置数组只包含几千个“未定义”条目我做错了什么?我尝试了各种方法,但结果总是一样的,所以我将问题浓缩到下面并希望得到一些帮助
//Subscribe to the output of user ids, when we get a hit (delivered as an array of Observable DataSnapshot) loop through and subscribe to all the children of this location
this.userConfigs$ = this.userIds$.pipe(
switchMap(itemIds => {
let configs = itemIds.map(itemId => {
let pathOrRef = '/AIS/USERSAVEDCONFIGS/' + itemId.key;
console.log('tomato');
db.list(pathOrRef).snapshotChanges(['child_added']);
});
return configs;
})
);
我开始了整个事情
this.userConfigs$.subscribe();