I have a function updateNodes()
. My await
to the getFont
external function is not "waiting" to move to the next line so it's treating every font as not seen and making a request. I am not awaiting this correctly?
_allFontSets = {}
updatesNodes() {
for (const [entity] of this._allEntities) {
const textObj = this._allEntities.get(textEntity);
const data = {
ranges: textObj.map(async (styleData)=> {
const font = styleData.font;
const stringified = JSON.stringify(font);
if (Boolean(this._allFontSets[stringified])) {
console.log("ALREADY SEEN FONT")
font = JSON.parse(this._allFontSets[stringified]);
} else {
console.log("NEW FONT")
font = await getFont() //external service;
this._allFontSets[stringified] = font;
}
}
}
}
}