You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently I decided to switch to using computed properties returning this.$autorun() instead of meteor property, because of this #49 issue. But encountered another issue. Computed property returning this.$autorun() becomes reactive only if it has any reactive property (data or props) inside function body. Here are two examples illustrating the issue:
<!--reactiveexample--><template><div>{{reactiveItems.length }}</div></template><script>constItems=newMongo.Collection(null)Meteor.setInterval(()=>{Items.insert({})},2000)exportdefault{data(){return{anything: undefined}},computed: {reactiveItems(){this.anything// This line enables reactivityreturnthis.$autorun(()=>Items.find())},},}</script>
Now the question is whether it is an issue at all? The only provided example in docs relies on reactive this.sort property, so probably it is an expected behavior? If so, we should update the README to make it clear.
The text was updated successfully, but these errors were encountered:
red-meadow
changed the title
$autorun should rely on reacive property to work
$autorun should rely on reactive property to work
Jun 3, 2019
Recently I decided to switch to using computed properties returning
this.$autorun()
instead ofmeteor
property, because of this #49 issue. But encountered another issue. Computed property returningthis.$autorun()
becomes reactive only if it has any reactive property (data or props) inside function body. Here are two examples illustrating the issue:Now the question is whether it is an issue at all? The only provided example in docs relies on reactive
this.sort
property, so probably it is an expected behavior? If so, we should update the README to make it clear.The text was updated successfully, but these errors were encountered: