Chapter 2. Publish and Subscribe Patterns
This is by far the most important chapter in this book. The way we control our publishers and subscribers is going to define how quickly our application responds in production. Publishers and subscribers are the link between our database and the client. The server uses publishers to publish information to the client, while the client requests information from the publishers by subscribing to them. This is all managed via the Meteor.publish
and Meteor.subscribe
functions. We should be able to produce the data that the client wants to see with two objectives in mind:
- Reduce stress from the server
- Send only the information that the client needs
This chapter will teach you the different patterns that you can use to attain these objectives for every template that you build. Here is an overview of the topics we will cover to understand these patterns:
- Template-level subscriptions
- Database relationships
- Publishing with relations
- Aggregation publishers...