meteor-vue / vue-meteor-tracker

Use Meteor Tracker reactivity inside Vue components
90 stars 20 forks source link

$subReady always false #31

Closed skwerlzu closed 6 years ago

skwerlzu commented 6 years ago

I am brand new to the vue + meteor stack, so forgive me if this is a dumb question.

I am having trouble retrieving any db data. $subReady is always false and queries are returning empty data.

Being new to both meteor and vue I am not able to find where I am going wrong. May be simple, but is escaping me. Any help will be greatly appreciated.

I am trying to get the basics of retrieving and displaying static data as well as reactive. Most example I find are different file structures and short on a the full function flows, so it's tough for a new comer to trace and relate.

// export default //
data () {
    return {
      newNote: '',
      limit: 5,
      sort: true,
        selectedTrekId: null
    }
  },
  meteor: {

    $subscribe: {
      'treks' () {
        return [this.limit]
      },
    },
    treks () {
      return Treks.find({}, { sort: { _id: -1 }})
    },
    // Selected thread
    selectedTrek () {
      // You can also use Vue reactive data inside
      return Treks.findOne(this.selectedTrekId)
    }
  },
  computed: {
    allTreks () {
      return this.treks 
    },
    treksCount () {
        return this.treks.length
      }
  },
  watch: {
    '$subReady.treks' (value) {
      console.log('Watch - Subscription Ready: '+value)
    },
  },

have also tried the mounted method

`this.$subscribe('treks', 'new', 10);
          console.log('Mounted - Sub Ready status: '+this.$subReady.treks)

Trying to display with

<p> Testing Reactive Var: {{allTreks}}</p>

                        <p>Testing Trek Count: {{treksCount}}</p>

                        <div v-if="!$subReady.treks">Loading...</div>

Results are Testing Reactive Var: [] esting Trek Count: 0 Loading...

Akryum commented 6 years ago

Could you share a link to a repository reproducing your issue?

skwerlzu commented 6 years ago

Unfortunately, no. Its isnt something I can make publicly available.

I can share snippets of anything you think may help.

Collections are set up as normal and included. Its pretty much basic as the instruction examples that are given currently.

Akryum commented 6 years ago

Well maybe you can do a simple project that reproduces the issue which is not your current project.

skwerlzu commented 6 years ago

Sorry for the delay. I created a private git. If you are willing to take a look, I can add you as a collaborator.

Akryum commented 6 years ago

Go ahead!

Akryum commented 6 years ago

Check the name of your publication (treksAll).

skwerlzu commented 6 years ago

I knew it would be something simple and stupid. You sir are a scholar and a gentleman.