Proper place for global subscription?

Hi,

What is the proper place for global subscription?
I am using flowrouter but FlowRoutersubscription registration mechanism will be removed in version 3.0
I have several layouts and some subscriptions are used in all layouts.
What is the correct approach?

The best place would be within a meteor startup function. The best file depends a bit on your file structure. I you use React, your App.jsx would be the best place. If you use React in combination with redux, it might be best to place it as a reduc action in combination woth tracker as part of ypur AppActions.

For Blaze I would put it in a startup function in my app.js file (the one that loads my app.html)

1 Like

For global global subscriptions, use a null publication at startup function. This would automatically publish this data that you need for the app without the need to actually subscribe to it on the client.

Meteor.publish(null, function() {
    //return cursor or array of cursors here
}, {is_auto: true});