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

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -