mmlpxjs / mmlpx

🐘 mobx model layer paradigm
MIT License
180 stars 10 forks source link

How watch @observable in mobx-vue? #2

Closed snice closed 6 years ago

snice commented 6 years ago
export default class DatasourceViewModel {
 @observable public activePid: string = 'loading';
}
export default class Datasource extends Vue {
  @inject() public store: DatasourceViewModel;
  activePid: string = 'loading';
  $refs: {
    tableStruct: TableStruct,
    tableData: TableData,
  };
 //@Watch('store.activePid')
  @Watch('activePid')
  onActivePidChanged(val: string, oldVal: string) {
    this.$refs.tableStruct.packageId = val;
  }
}
kuitos commented 6 years ago

use the observe api in mobx https://mobx.js.org/refguide/observe.html#observe

kuitos commented 6 years ago

Thanks for your feedback!