filrak / vue-offline

Offline states and storage for Vue PWA
MIT License
349 stars 20 forks source link

Default values in additional configuration #26

Open alexdeia opened 2 years ago

alexdeia commented 2 years ago

Hi. Are you sure that option object works properly? Because when I tried to reproduce disabling of one any features

Vue.use(VueOffline, {
    mixin: false
})

or

Vue.use(VueOffline, {
    storage: false
})

I got completely disabling them.

Look into options and default values.

export const VueOfflinePlugin = {
  install (Vue, options = { mixin: true, storage: true }) {
    const pluginOptions = {
      mixin: options.mixin,
      storage: options.storage
    }
    if (pluginOptions.storage) Vue.prototype.$offlineStorage = VueOfflineStorage
    if (pluginOptions.mixin) Vue.mixin(VueOfflineMixin)
  }
}

One of the params overwrites the other to undefined. I prepared the PR this -> https://github.com/filrak/vue-offline/pull/25