in src/logic/BrazeMessages.ts [153:179]
private getMessageForSlot(slotName: MessageSlotName, articleContext?: BrazeArticleContext) {
// If there's already a message in the cache, return it
const firstRenderableMessage = this.getHighestPriorityMessageFromCache(
slotName,
articleContext,
);
if (firstRenderableMessage) {
return Promise.resolve(firstRenderableMessage);
}
// Otherwise we'll wait for a fresh message to arrive, returning the
// data from the cache (where it will have already been added)
return this.freshMessageBySlot[slotName].then(() => {
const firstRenderableMessage = this.getHighestPriorityMessageFromCache(
slotName,
articleContext,
);
if (firstRenderableMessage) {
return Promise.resolve(firstRenderableMessage);
}
// Generally we don't expect to reach this point
throw new Error(`No valid messages for ${slotName} slot`);
});
}