1

basically I have:

Meteor.startup(function () {
   "use strict";

   Meteor.publish("uTree", function () {
        return utree.find({});
   });
});

so the question is should I wait or not for the system is up and running to start publishing? is any advantage of using Meteor.startup() in here?

juanp_1982
  • 917
  • 2
  • 16
  • 37

1 Answers1

4

short answer

The startup callback is unnecessary in this case.

long answer

The only reason you'd wrap a publisher in a startup callback is out of concern that some part of the server code (a package, collection, etc.) had not yet been evaluated.

In order for a publish function to be activated, there needs to exist a connected client making the request. In order for a connected client to exist, the server must already be running. If the server is already running, it has already evaluated all of its scripts.

Therefore, the startup callback is unnecessary in this case. Q.E.D.

David Weldon
  • 63,632
  • 11
  • 148
  • 146