mobxjs / mobx-vue

🐉 Vue bindings for MobX
MIT License
475 stars 22 forks source link

Is there a way to add mobx to vue plugin component inside Vue.component, Vue.extend install function? #87

Open ColtHands opened 2 years ago

ColtHands commented 2 years ago

Basically i want to add my state globally through install fn, but I can't seem to find any examples.

export default {
    install(Vue, options) {
        // this will work, but wont be observable by component
        Vue.prototype.state = new StateClass()

        // I want to add mobx on this step, state above will work, but wont be observable
        Vue.component('MyCustomComponent', Vue.extend(MyCustomComponent))
    }
}
ColtHands commented 2 years ago

I've tried multiple things but i can't seem to find a way to define mobx-vue globally. Are there any examples like that?


new Vue({
  components: ...,
  state: new ViewModel()
}).mount("#app")