zhouzhuojie / meteor-vue

Vue for Meteor
130 stars 8 forks source link

NOT reactive when using vm's data or props as params #20

Open zhongqf opened 8 years ago

zhongqf commented 8 years ago

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.

nerijunior commented 8 years ago

@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){
...
});
niallobrien commented 8 years ago

Running a computed property would be a better idea.

zhouzhuojie commented 8 years ago

Agreed. This is a good idea, so one of the data change flows can be

$data -> computed -> Tracker -> $sync to data

zhongqf commented 8 years ago

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.

niallobrien commented 8 years ago

This could be possible with Browserify (at least I think Meteor uses Browserify). I have it working using Webpack outside of Meteor.

zhongqf commented 8 years ago

@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.

beeplin commented 8 years ago

https://github.com/almini/vue-meteor this project might be a solution for @zhongqf .