aarondfrancis / vue-model

Model component for Vue.js
MIT License
855 stars 42 forks source link

SSR support #26

Open dvasyliev opened 6 years ago

dvasyliev commented 6 years ago

Hi, very nice implementation of models in Vue! Could you provide integration with SSR or help me, how I can do it?

I did my SSR like here and I need to get model variable in asyncData hook like in this example we have store variable (also we have ability to register store module):

export default {
  asyncData ({ store }) {
    store.registerModule('foo', fooStoreModule)
    return store.dispatch('foo/inc')
  },
  ...
}

Source of code

With models it should be like this:

import MyModel from './myModel.js'

export default {
  asyncData ({ model }) {
    const myModel = model('myModel', myModel)
    return myModel.http. fetch()
  },
  ...
}

It will help me load data to my model on the server side and when my page rendered, my model will be filled. Nowadays SSR very popular and a lot of people use it!

If you need some help about SSR explanation you can write me. Thank you!