0

I'm developing a chrome extension and willing to know, if storage.sync synced first before firing onInstalled event. Am i supposed to do something like this:

browser.runtime.onInstalled.addListener(async () => {
  const { profileId } = await browser.storage.sync.get(['profileId']);
  // get user from API and save to storage.local
});

to get user synced between devices? Or should i do it in any other place?

If i got it right, there is no way to check it out before publishing my extension. Or maybe is there a way to sync chrome extensions installed locally?

Thanks.

zoryamba
  • 196
  • 11
  • Installation doesn't wait for storage so you should use await there. I also suggest using browser.storage.onChanged event to process future syncs too. – wOxxOm Sep 16 '21 at 13:08
  • Is there any event on storage first sync? I can wait for eternity in case if it's first installation :-/ – zoryamba Sep 16 '21 at 13:10
  • There's no such event... – wOxxOm Sep 16 '21 at 13:18
  • 1
    I think there is no clean way. There is an old answer https://stackoverflow.com/questions/24013718/chrome-extension-wait-for-storage-sync-to-get-remote-data – Johan Hoeksma Sep 16 '21 at 14:08

0 Answers0