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.
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 byvm.$watch()
to initialize Vue Watcher and then executed byTracker.autorun()
in order to initialize Computation.Proposed changes:
Tracker.autorun()
callback withcomputation.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.