I have a long task that is running in background.js, and I want to send a message to popup.js upon completion. However, if the page action has not been clicked when the message is sent, the listener in popup.js will not yet have been registered, and the message will not be received.
I could instead send a message from popup.js and request the background task's result in response. However, there is no guarantee that the task will have finished at that point in time.
The only solution I see is a combination of the two: setting up a listener in both files and sending messages back and forth, saying things like: "Here's the result if you can hear me!" and "I can hear now! Send me a result if you're finished." However, this solution seems overly complex for such a simple task.
So, isn't there some place where background.js can place the result for popup.js to retrieve at its own leisure?