Got these two methods. I have a class which calls the method getFamily before this.family is assigned since onSnapshot has not finished loading. How can i restructure this so a call to getFamily will wait for onsnapshot to finish? Is it possible to use promises?
getFamily() {
return this.family;
}
setFamilyID(familyID) {
this.familyID = familyID;
this.db.collection("families").doc(this.familyID).onSnapshot((familyDoc) => {
console.log("family updated");
this.family = familyDoc;
});
}