Stop using them
Yes you read that right, unless you want to create a custom functionality that uses the beautiful LiveData utilities from Meteor, stop using publications, instead leverage Grapher for this.
If you would like to find one post and have it react to changes you will create a NamedQuery:
1 | // file: /imports/db/posts/queries/getPost.js |
1 | // file: /imports/api/posts/queries/getPost.expose.js |
In the client you will use it something like this:
1 | import getPostQuery from '/imports/db/posts/queries/getPost'; |
The advantages are the following:
- No need to do big changes if you decide to make a query non-reactive
- Separates the concern of data fetching
- Brings modularity and easy linking with other collections.
You have to use Grapher in your Meteor app if you want to bring it to enterprise standards. Period. It’s the best way we know.