nighca / movue

MobX integration for Vue.js.
Apache License 2.0
59 stars 13 forks source link

Add support for fromMobx attributes being pulled from mixins #22

Closed Tresky closed 6 years ago

Tresky commented 6 years ago

I have run into a limitation of Movue while working on an application. The current functionality of the library does not allow loading fromMobx attributes from a mixin on a component. See example below:

const data = observable({
  foo: 1
})

const mixin = {
  fromMobx: {
    foo () {
      return data.foo
    }
  }
}

const vm = new Vue({
  mixins: [mixin],
  computed: {
    value () {
      // This value will be undefined in the current version.
      // This PR allows this to work.
      return this.foo
    }
  },
  render (h) {
    const vm: any = this
    return h('div', `${vm.value}`)
  }
})

As it stands, right now, the value foo will not be defined in the top-level component. This pull request pulls fromMobx attributes from mixins one-level below the top-level component to allow Movue to be used in mixin abstraction.

I have submitted a Pull Request at #21

EDIT: Spelling and adding a comment.

nighca commented 6 years ago

Released in v0.3.0.