meteor-vue / vue-meteor-tracker

Use Meteor Tracker reactivity inside Vue components
90 stars 20 forks source link

Fix double execution of meteor properties functions #60

Open red-meadow opened 5 years ago

red-meadow commented 5 years ago

Fixes #49 (partially)

As described in the issue, meteor properties functions (without $lazy) are executed twice during component creation. The reason for this behavior is that a function is first executed by vm.$watch() to initialize Vue Watcher and then executed by Tracker.autorun() in order to initialize Computation.

Proposed changes:

I don't really like this solution but it seems to be working without side effects. The drawback is an additional condition checking on each autorun execution.

@Akryum, I found several of your comments about separating the Tracker and Vue callbacks but I am not sure whether they are related to this PR or you meant a deeper integration. I must admit that my understanding of Watcher and Tracker insides is not enough to conclude whether proposed changes are safe, so I will be grateful for the PR review and possible comments.