title: Meteor : Publish data from external source (socket)
body: <p>I am using the getstream.io API with their library. They have the following hook in their JS library :</p>
  
  <pre><code>newsFeed.subscribe(function callback(data) {
          //do something with the data   
   });
  </code></pre>
  
  <p>I created a package to wrap the NPM library.
  I want now to use this function and publish the results to a client only collection.</p>
  
  <p>I'm going to try this but I don't know if it's ok :</p>
  
  <pre><code>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();
  });
  </code></pre>
  
  <p>Is this ok ? Or should I do it this way ?</p>
  
  <pre><code>// This will be used to store the subscription objects for later management
  var subs = { };
  
  // The 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) {
          for (var subscriptionID in subs) {
               var subscription = subs[subscriptionID];
               subscription.added("clientNewsCollection", Random.id(), {event: data});
          }
    });
  </code></pre>