title: PWA: Polling for data in the background
body: <p>My PWA App needs to poll for new "Notifications" from an API while the app is being used or in the background.</p>
  
  <p>I am using <strong>NuxtJS</strong> with <strong>Vuex</strong> and already have an action (Promise) that performs the request and adds to state and as well as Indexed DB.</p>
  
  <p>I need to call this action every 5 minutes and create notifications for id's in the response that I have not yet seen.</p>
  
  <p>I can do the notification part, but I do not know <strong>how to call my Vuex action</strong>. Can I dispatch the action or do I need to import my promise into the service worker somehow?</p>
  
  <p>In Nuxt PWA [<code>nuxt.config.js</code>] you can add files to the <code>pwa.workbox.importScripts</code> array, but including one of my <code>store</code> files does not work, since the service worker is looking for files in it's own directory and my store files have been compressed e.g.</p>
  
  <pre><code>pwa: {
    workbox: {
      importScripts: [
        'custom_sw.js',
        '~/store/test.js'
      ]
    ...
    }
  }
  
  </code></pre>
  
  <p>If there is no way for me to do either, I'll just have to rewrite the fetching and parsing code, but this is quite inefficient.</p>
  
  <p>I would greatly appreciate any advice!</p>