filrak / vue-offline

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

Fix setting options #25

Closed alexdeia closed 2 years ago

alexdeia commented 2 years ago

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.

filrak commented 2 years ago

Thanks! I need to come back and refactor this lib anyway, it's been sooo long ;)