-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Meteor properties over reactive? #49
Comments
Same here, the meteor.property is being run at least once when the page is rendered regardless of whether it is used in the template or not, even with $lazy='true'. What's worse, it can result in unexpected errors if the meteor.property relies on props or data which might be invalid in that situation. e.g: <template>
<div>
<div v-if="user">{{user.profile.name}}</div>
<div v-else>
all users:
<ul><li v-for="u in allUsers" :key="_id">{{u.profile.name}}</li></ul>
</div>
</div>
</template>
<script>
export default {
props: ['user', 'query'], // we only need one of these
meteor: {
allUsers() {
return Meteor.users.find(this.query, {fields: {"profile.name"}: 1);
}
}
}
</script> (this is a contrived example, but I have some real world experience of this bug in more complicated components.) Here the My work-around is to do this instead: export default {
props: ['user', 'query'], // we only need one of these
computed: {
allUsers() { return this.$autorun(() => {
if (!this.query) console.error('component called without any valid props');
return this.query ? Meteor.users.find(this.query, {fields: {"profile.name"}: 1}) || [];
})}
}
} Now the |
@Akryum are there any chances you could pay attention to issues with Meteor integration? To me (and hopefully to many), native Meteor (with Tracker and MiniMongo) has more advantages than Apollo. |
@vblagomir @wildhart Hello, guys! I decided to look under the hood and try to fix this. It turned out that we have two separated issues here: when The behavior of I created two PRs: #60 and #61. I'm not sure any of them will/could be merged but I hope they will be at least reviewed. |
In the above example:
Expected behaviour:
The 'test2' should not trigger at all when '$lazy' is enabled, or be triggered only once when $lazy is disabled.
Notes:
'Vue.config.meteor.freeze = true' does not fix it either.
The text was updated successfully, but these errors were encountered: