jeffreyguenther / vue-turbolinks

A Vue mixin to fix Turbolinks caching
MIT License
287 stars 20 forks source link

Confusion in README instructions #14

Closed jeffreyguenther closed 6 years ago

jeffreyguenther commented 6 years ago

In the readme, we write:

import TurbolinksAdapter from 'vue-turbolinks'
Vue.use(TurbolinksAdapter)

export default {
  data: function () {
    return {
      message: new Date
    }
  }
}

@excid3 I don't believe this works. There is no reference to Vue in app.vue, or any single file components. I think the lines to set up the mixin need to be added in the place where you call new Vue(...). Or am I missing something?

excid3 commented 6 years ago

I’m not sure what you mean? When you call Vue.use() it sets up the plugin for all vue apps.

On Thu, Nov 9, 2017 at 11:46 AM Jeffrey Guenther notifications@github.com wrote:

In the readme, we write:

import TurbolinksAdapter from 'vue-turbolinks' Vue.use(TurbolinksAdapter)

export default { data: function () { return { message: new Date } } }

@excid3 https://github.com/excid3 I don't believe this works. There is no reference to Vue in app.vue, or any single file components. I think the lines to set up the mixin need to be added in the place where you call new Vue(...). Or am I missing something?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jeffreyguenther/vue-turbolinks/issues/14, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEGFdZnCO4tHQZAG4shMozkAAmwuC-yks5s0zqIgaJpZM4QYX_q .

-- Chris Oliver http://excid3.com | @excid3 http://twitter.com/excid3 | http://github.com/excid3

jeffreyguenther commented 6 years ago

If the Vue object is defined, it does. In a single file component, the variable Vue is not in scope.

excid3 commented 6 years ago

Ah yeah. Well TurbolinksAdapter should only be included once globally, not inside a single file component.

jeffreyguenther commented 6 years ago

Ya, that's what I'm getting it at. The README is not clear about this. I just wanted to make sure I wasn't missing something that you knew. I'm going to update that section to make it easier to get started. I've been using Vue more lately, so I can write a more informed guide.

excid3 commented 6 years ago

Good call. I hadn't noticed.

Both of those first examples can probably just be condensed into one to include it once globally.