title: How to send a variable from server to client in meteor?
body: <p>I have a page with text input and a button. When I insert link to youtube video into text field and press the button - video downloads into the local folder.</p>
  
  <p><strong>The problem:</strong> how can I send link to local copy of the downloaded video back to the client?</p>
  
  <p><strong>More general question:</strong> How can I send a variable from server to client (this variable is temporary and is not going to be stored anywhere) ?</p>
  
  <p>The code I have right now:</p>
  
  <h3>Client code</h3>
  
  <pre><code>if (Meteor.isClient) {
      Path = new Meteor.Collection("path");
      Meteor.subscribe("path");
  
      Template.hello.events(
          {
              'submit .form' : function() {
                  var link = document.getElementById("youtube-url").value;
                  Meteor.call('download', link);
                  event.preventDefault();
              }
          }
      );
  }
  </code></pre>
  
  <h3>Server code ('collection' part is not working)</h3>
  
  <pre><code>if (Meteor.isServer) {
      Meteor.startup(function () {
  
          Meteor.methods({
              download: function (link) {
                  var youtubedl = Npm.require('youtube-dl');
                  var Fiber = Npm.require("fibers");
                  var dl = youtubedl.download(link, './videos');
  
                  // called when youtube-dl finishes
                  dl.on('end', function(data) {
                    console.log('\nDownload finished!');
                    Fiber(function() { 
                        Path = new Meteor.Collection("path");
                        Path.insert({path: './videos/' + data.filename});
                    })
                  });              
              }
          });
      });
  }
  </code></pre>
  
  <p>Thanks!</p>