nuxt-community / localforage-module

Localforage module for Nuxt.js
MIT License
88 stars 5 forks source link

Question and localforage in `modules` not `buildModules` #12

Closed transfluxus closed 4 years ago

transfluxus commented 4 years ago

Hi,

Any notes on the new version? :) I am still on 1.0.2

I am doing something typical, reloading the storage when the app is loaded. My approach so far is to put it in the create method of my default layout. obviously that is problematical since I would need to do that in all other layouts. I was thinking about doing this in an middleware, however I just noticed, that the localforage is not available in the context of the middleware. I was checking the documentation, to see if there is something about that... Doing that I realized I have localforage in modules not buildModules. However changing that, my index page doesn't load anymore...

I am doing something like this in the default layout:

    created() {
      if (!this.$store.getters[DB_LOADED]())
        reload_storage(this.$store, this.$localForage) 

db_loaded is a flag in my store which is set after localForage is loaded. Then in a watch method to that store variable I fetch stuff from the server and set another flag in the store to initialized, which will finally allows the page to be created:

      <v-container v-if="initialized">
        <nuxt/> 

There is probably a better way to do all these initial steps involving the localforage. Any guidelines would be really appreciated.

This question is available on Nuxt community (#c12)
ghost commented 4 years ago

This issue as been imported as question since it does not respect localforage-module issue template. Only bug reports and feature requests stays open to reduce maintainers workload. If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically. Your question is available at https://cmty.app/nuxt/localforage-module/issues/c12.