Joining flattened data is a common use case also described in the documentation. But the documentation shows a simple example which is not real-time, it doesn't react to changes. I'm looking for a more robust implementation. I think RxJava is ideal for this.
Consider following Firebase structure:
{
"messages": {
"group_id_1": {
"message_id_1": {
"text": "Hello",
"author": "uid_1"
}
}
},
"users": {
"uid_1": {
"name": "David"
}
},
"rooms": {
"room_id_1": {
"name": "General",
"members": {
"uid_1": true
}
}
}
}
I see two use-cases here:
- Get list of messages in a group with author names
- I imagine I would get
Observable<Message>
and when I subscribe to it, dependencies (users for those messages) will be subscribed as well in some cache. When I'm showing the messages, I can get author's names from the cache. - It's also real-time - if author name changes, the observable emits changed Message.
- When I unsubscribe to the observable, also dependencies unsubscribes.
- I imagine I would get
- Get a list of room members with their names
- I imagine I would get
Observable<User>
and when I subscribe to it, it will first subscribe to room's members and then to individual users. - It's real-time - if room members change, I get notified about that.
- When I unsubscribe to the observable, also dependency unsubscribes.
- I imagine I would get
Do you know about library/solution which could do that?
Or would you use it if I created one?