I need to subscribe multiple times in order to get the right data fro my NoSQL database. In order to fetch user list of specific project, I do this:
ngOnInit() {
//Subscription 1 (Service): Get project data
this.projectService.getCurrentproject().take(1).subscribe(projectData => {
console.log('Got project data.');
//Subscription 2: Get project user IDS
this.af.database.list('/project_roles/'+projectData.$key)
.subscribe((userMeta) => {
});
});
}
As you can see, a subscription, inside a subscription, inside a subscription.. And each subscription depends on the previous one reslt.
Subscription 3 and 4 can be parallel.
The code works well, but am I missing something or this is how I suppose working with multiple subscription that the result of the previous one depends the next?
Update: There seem a problem with Subscription #2. The subscription is not yet complete but I start iterating over the list, which give me a double user list!