Installation
`meteor npm i --save meteor-publication'
Usage
Create a publication:
; ;
Use the publication you created:
; fooPublication;
This replaces the traditional way of creating and calling Meteor publications:
; // Create a publicationMeteor; // Subscribe to the publicationMeteor;
This removes reliance on magic strings and enables type checking if you use TypeScript (see below).
API
Publication#subscribe
: returns a standard Meteor subscription object with stop(), and ready() methods, and the subscriptionId property.
Publication#withData
: returns an object with a subscribe method that, when called, will subscribe with the data you supplied in this call.
Notes for TypeScript:
This module comes with typings. Visual Studio Code supports full type inference:
;;fooPublication.call1; // Error since you are passing a number instead of a date
TypeScript currently doesn't support inference if you have 0 arguments, so this will give you an error:
;;fooPublication.call; // Error because TypeScript still thinks you should pass an argument.
Instead, use the PublicationWithoutArgs
class:
;;fooPublication.call; // All good