Meteor publication.ready returning false

I’m trying to use Meteor’s pubsub pattern but my publication is returning false on ready(). This seems to be a bit of an anomaly, there aren’t many issues of this kind on the internet - which probably means I’m missing something basic, anyway here we go:

// in /app/server/collections/clubs.js
import ClubSchema from '../schemas/clubs.js';

export const Clubs = ( function() {              // <- tried refactoring to 
    var clubs = new Mongo.Collection('clubs');   //    standard collection declaration
    return clubs;
} )();

// in /app/server/publications/clubs.js
import { Clubs } from '/app/server/collections/clubs.js';

Meteor.publish('clubs', function () {
  console.log("hello, world!");
  return Clubs.find();

// in /app/client/templates/new-club.js
Template.App_clubs.onCreated(function () {

On the first run, Meteor.subscribe('foo').ready() returns false, since it has no data yet. But it is a reactive variable, so it’ll re-run once it is ready (only if it’s inside a reactive context).

The same way, the subscription is deleted once your reactive context is destroyed. Take a look at the docs for subscribe

1 Like

Yeah, got to the bottom of it - as you say it becomes ready once it receives the documents… stuck it in an autorun and hey-presto; it returned true.

1 Like