Global push notification using Cursor.observe()?


So, I’m working on my first Meteor application, and I’m trying to set up a “follow” system for users that will allow them to follow other users and follow content.

When a user performs an action, or an action is performed on a piece of content, I’m going to insert a document into an “Events” collection, to serve as an activity log.

Follows will exist in a collection as well, in a format like this:

    _id: <duh>,
    mod (or user): <ID#>,
    createdAt: <date>

So, what I’m needing to do is…attach some sort of observe() to the Events collection (subscription, anyway) that triggers when a new event is added. I just…am sort of lost and don’t really know where to go from here. Basically, if the person is following a user, and an event is added to the collection due to that user doing something, I want the observe() to trigger and send a notification to the client.

I guess this sounds sort of convoluted, but…I figured it couldn’t hurt to ask here. I know pub/sub will obviously become involved. I just didn’t know how to have a Cursor.observe() be able to affect the entire application for a client. I want these messages to come up no matter what page they’re on. Should I be using the base layout somehow? Template.layout.onRendered, etc?

Thanks in advance, folks!


Why not just use the regular pub/sub? The data is available everywhere then.

Meteor.startup(function () {Meteor.subscribe("records")})