I am currently stuck in a problem with Firebase Observable joins.
I really don't know which of the best ways to get my data from different objects and combine them.
My data structure:
users {
userid1 {
conversationid: id
...
},
userid2 {
...
}
}
conversations {
conversationid {
...
}
}
Now I want to get all the conversations of the current user. To get the current user id, I will subscribe to auth. We observe as follows:
this.af.auth.subscribe(auth => {
console.log(auth.uid);
});
As the next one, I need a child of the user to get the conversation id. I do it like this:
this.af.database.object('/users/' + auth.uid)
.map(
user => {
console.log(user.conversationid);
}
)
.subscribe();
And the same for talking:
this.af.database.list('/conversations/' + user.conversationid)
.subscribe();
As you can see, there are 3 observations. I know that it is possible for them to nest, but in my project this can happen up to 5 times.
Is it possible to get conversations without nesting 3 observables?