I struggle a lot with some basic changes in my application. I have been doing this for several days and am losing my will! I wonder if anyone here can point me in the right direction.
I have a group with 2 user lists. One for members and one for moderators .
This method connects to the database to get a list of objects, each of which has a value of $key . Now I want to use these keys and get the actual UserData for each user. I tried everything and combineLatest is the only thing I could get to work.
This way both function calls, and I use the async tube in my template.
members$ = myService.getMemberListByType("blah", "members"); moderators$ = myService.getMemberListByType("blah", "moderators");
My function looks like this.
private getMemberListByType(groupKey: string, memberType: string) { return this.af.database.list(`groups/${groupKey}/${memberType}`) .switchMap(userListKeyMap => { console.log("UserListKeyMap", memberType, userListKeyMap); let usersObservables: Observable<UserData>[] = []; userListKeyMap.forEach((object) => { usersObservables.push(this.af.database.object(`users/${object.$key}`) .map(UserData.fromJSON)); }); return Observable.combineLatest(usersObservables); }); }
However, Angular does not detect changes to this list as follows. Say another method elsewhere removes member and adds it to moderator . In this case, the members list emits an empty user list [] .
My * ngIf and * ngFor do not detect changes in this new empty object. As a result, the user (in the template) is now included in 2 lists, but the data in it is absolutely accurate, as highlighted by the log.
I feel that when I combine Latest with an empty array, this is the source of my problem. Nothing can emit ... so how can Angular change? I do not know how to solve this. Is there an alternative to combLatest in this "empty" use case? Since I'm using an async handset, I need something that makes sense.
Can anyone highlight my problem?
Thanks!
Update
I am convinced that the problem is that angular2 does not detect an empty observable list. In particular, when the value of the observed array matters, but later that value becomes empty. angular2 will not see an empty array. I currently have no way to solve this problem. Or is my approach wrong, or should something specific happen to register an empty observable list?

- Blue = Component loading status is good, the user was a member.
- Green = User has been moved from member to manager / moderator.
- Red = this does not exist, so why is it still displayed?