MILANO
19/03/2015
Introduction to Publications and Subscriptions, the magic behind the reactivity
Matteo Saporiti
Dev4Side .NET/JS/HTML/Whatever is needed developer
Yeah, I actually find the hat guy from xkcd likeable.
Advanced uses
How publications work under the hood
__________________________
__________________________
__________________________
DDP
MongoDB
Â
Meteor.publish()
Minimongo
Â
Meteor.subscribe()
A basic publication and subscription
Send only the data the client needs.
Send only the object fields that the client needs
Multiple publications over the same collections may lead to unexpected results because the data are merged in the client.
This is because of the mergebox.
Hide some data to non registered users.
It's possible to make publications smarter and differentiate the data that are sent to the client.
You should try to avoid having a publication with multiple possible values in queries.
Meteor does reuse the observer for successive requests, having different query make this optimization impossible and may lead to slowdowns.
How a publication works internally and some nice tricks that you can easily accomplish.
All the customizations do not change the query, so you can actually do this without having an impact on the performance.
The code used in the presentation is available at
https://github.com/matteosaporiti/Meetup_19_03
Slides will be available later on.