When is null ready?

Having the following code on the server:

Meteor.publish(null, function(){ // Return some cursors. }) 

according to the documentation, it has the following effect: a set of records is automatically sent to all connected clients.

How can I determine on the client side whether all documents published by this function have been received? If I used the subscription instead, it would provide me with a ready-made callback, letting me know when all the documents were received. What fits here? Or documents already received on the client when my client code starts to execute?

+7
meteor publish
source share
1 answer

I’m afraid that you don’t have a ready-made callback for the so-called universal subscriptions you mentioned above. Just browse through this part of the Meteor code, where the publish and subscription logic is defined on the server. For convenience, I copy / paste the code below:

 ready: function () { var self = this; if (self._isDeactivated()) return; if (!self._subscriptionId) return; // unnecessary but ignored for universal sub if (!self._ready) { self._session.sendReady([self._subscriptionId]); self._ready = true; } } 

_subscriptionId specified only for named subscriptions, which will be determined manually using the Meteor.subscribe method. Subscriptions corresponding to null publish functions do not have their own _subscriptionId , as you can see from the above code, the server is not an event trying to send a ready message to the client.

+8
source share

All Articles