Last active
June 8, 2017 15:15
-
-
Save SachaG/7b4676b39d865aba1903e8e681acdb8a to your computer and use it in GitHub Desktop.
Publishing Counts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Meteor.isClient) { | |
NovaCounts = new Mongo.Collection("novacounts"); | |
} | |
if (Meteor.isServer) { | |
NovaCounts = { | |
subscription: {}, | |
counts: [], | |
push(listId, count, sessionId) { | |
this.subscription.added("novacounts", listId, {count: count}); | |
if (!this.counts[sessionId]) { | |
this.counts[sessionId] = {}; | |
} | |
this.counts[sessionId][listId] = count; | |
} | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.publish('counts', function() { | |
const self = this; | |
NovaCounts.subscription = self; | |
self.ready(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.publish('posts.list', function (selector, options) { | |
const posts = Posts.find(selector, options); | |
NovaCounts.push(terms.listId, posts.count(), this._session.id); | |
return posts; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment