meteor-vue
meteor-vue copied to clipboard
NOT reactive when using vm's data or props as params
Look at this sample
var vm = new Vue({
el: '#vue-demo',
data: function() {
listId: 1
},
sync: {
items: function() {
return Lists.find({listId: this.listId})
}
}
}
items
is not updated even when listId
changed.
@zhongqf Think in sync object like the methods in "original" vuejs model, when data changes the methods wasn't executed too, right?
If you want to run some method when data['listId'] changes you'll need to use the $watch:
vm.$watch('listId', function(value){
...
});
Running a computed property would be a better idea.
Agreed. This is a good idea, so one of the data change flows can be
$data -> computed -> Tracker -> $sync to data
Thanks. @zhouzhuojie could you give some code example? And, Is there any possibility that merge/connect Vue and Meteor's dependency system? so that we could make Vue as first-class template engine of Meteor just like Blaze.
This could be possible with Browserify (at least I think Meteor uses Browserify). I have it working using Webpack outside of Meteor.
@niallobrien sorry, I'm not meaning the package dependency. I meant to merge/connect the data dependency mechanism (Tracker, Dependency ... in Meteor and $watch ,observer ... in Vue) that make vue/meteor reactive.
https://github.com/almini/vue-meteor this project might be a solution for @zhongqf .