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

How to pass `this.$subReady.posts` to data prop (reactive)?

Open thearabbit opened this issue 7 years ago • 2 comments

{{!$subReady.posts}} // work fine
{{loading}} // don't reactive
----------
data() {
            return {
                loading: true
            };
        },
        meteor: {
            $subscribe: {
                posts: []
            },
            loading(){
                return !this.$subReady.posts;
            },

thearabbit avatar Apr 29 '17 10:04 thearabbit

I try watch, but still don't work

watch:{
   '$subReady.posts':function(val){
      this.loading = val;
   }
}

thearabbit avatar May 01 '17 09:05 thearabbit

It should work with a computed.

export default {
  meteor: {
    $subscribe: {
      posts: [],
    },
  },
  computed: {
    isLoading() {
      return !this.$subReady.posts;
    },
  },
};

mathieustan avatar Jun 01 '18 14:06 mathieustan