Meteor : Publish data from external source (socket) -
i using getstream.io api library. have following hook in js library :
newsfeed.subscribe(function callback(data) { //do data });
i created package wrap npm library. want use function , publish results client collection.
i'm going try don't know if it's ok :
meteor.publish("newsfeed", function () { var self = this; var newsfeed = getstreamclient.feed('notification', 'newsfeed'); //todo : use meteorasync ? newsfeed.subscribe(function callback(data) { self.added("clientnewscollection", random.id(), {event: data}); }); self.ready(); });
is ok ? or should way ?
// used store subscription objects later management var subs = { }; // helper publication meteor.publish('newsfeed', function() { var subscription = this; subs[subscription._session.id] = subscription; subscription.onstop(function() { delete subs[subscription._session.id]; }); }); var newsfeed = getstreamclient.feed('notification', 'newsfeed'); //todo : use meteorasync ? newsfeed.subscribe(function callback(data) { (var subscriptionid in subs) { var subscription = subs[subscriptionid]; subscription.added("clientnewscollection", random.id(), {event: data}); } });
Comments
Post a Comment