title: Is there a created() for vuex actions to auto dispatch
body: <p>I have an action within vuex that I would like to auto dispatch within vuex itself rather than a component.</p>
  
  <p>I have created a notification bar that changes through different notifications which is on multiple pages. Rather than the notifications start from the beginning when I switch page I have created a store to set which notification to show.</p>
  
  <p>I would like to dispatch the rotate function in the vuex store from within vuex rather than from within a component</p>
  
  <p><em>Please note: I'm using Nuxt</em></p>
  
  <p><strong>VUEX State: store/notifications.js</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>export const state = () =&gt; ({
      section: 0,
      notifications: [
          'notification 1',
          'notification 2',
          'notification 3'
      ]
  })
  
  export const mutations = {
      INC_SECTION(state) {
          state.section ++
      },
      RESET_SECTION(state) {
          state.section = 0
      }
  }
  
  export const actions = {
      rotate({commit, dispatch, state}) {
              setTimeout(() =&gt; {
                  
                  let total = state.notifications.length -1
      
                  if (state.section === total) {
                      commit('RESET_SECTION')
                  }
                  else {
                      commit('INC_SECTION')
                  }
                  dispatch('rotate')
      
              }, 3500)
      }
  }
  
  export default {
      state,
      mutations,
      actions
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>VUE JS Component:</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;template&gt;
    &lt;section class="notifications"&gt;
      &lt;template v-for="(notification, i) in notifications" &gt;
        &lt;p v-if="$store.state.notifications.section === i" :key="i"&gt;{{notification}}&lt;/p&gt;
      &lt;/template&gt;
    &lt;/section&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
  export default {
    data() {
      return { notifications: [] }
    },
    computed: {
      setData() {
        this.notifications = this.$store.state.notifications.notifications
      }
    },
    created() {
      this.setData
    }
  }
  
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>