vue-meteor-tracker icon indicating copy to clipboard operation
vue-meteor-tracker copied to clipboard

Fix double execution of meteor properties functions

Open red-meadow opened this issue 5 years ago • 0 comments

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:

  • move watcher initialization inside Tracker.autorun() callback with computation.firstRun condition.

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.

red-meadow avatar Nov 01 '19 22:11 red-meadow