I use browser.runtime.onIstalled.addListener
for doing some presettings before starting the extension.
But in case the user starts Firefox with the extension already been installed I want to skip the presettings and start the extension right away.
How can i distinguish if I have to wait for the onInstalled
event or not?
Here the simplified code in the background script:
{
init() {
// invoke this.start if we don't have to wait for `onInstalled`
// (i.e. on browser start)
browser.runtime.onInstalled.addListener(details => {
this.preset(details).then(() => this.start());
});
},
start() { /* start app */ },
preset() { /* does some presettings on install and returns promise */ }
}