I would like to understand a basic concept regarding Firebase data structure and the callbacks.
If i have a users object:
users
userid
username: "my name"
userpic: "http://coolpic.jpg"
....
and posts object:
posts
postid
post message: "hello world"
userid: "12345"
My goal is to show a listView containing posts where each post shows the username + user pic (who wrote the post) and the post message. From what I've seen so far, if i call for post info, and then for user info (based on the userid within that post) the callback system gets the user info only after the view is populated. So i can't do something like :
- get post message + userid from posts object
- get user info from users object based on the userid i just got from posts object.
I noticed the "Promises" mechanic but it's only for Java Script, so the only solution i see is to store the user pic, and user name within the post object:
posts
postid
post message: "hello world"
userid: "12345"
username: "my name"
userpic: "http://coolpic.jpg"
Is there another solution? it seems like a nightmare to deal with, if a user wants to change his userpic or username.