title: Rxjs alternative for promise approach
body: <p>I'm trying to create wrapper module for fileupload feature.
  Below code looks to work fine for my scenario, recently i came across rxjs, and would like to know how i can convert below approach to Observable. What will be the advantage over promise.</p>
  
  <p><a href="http://mono.software/2014/07/07/Creating-NodeJS-modules-with-both-promise-and-callback-API-support-using-Q/" rel="nofollow">http://mono.software/2014/07/07/Creating-NodeJS-modules-with-both-promise-and-callback-API-support-using-Q/</a></p>
  
  <p>```</p>
  
  <pre><code>// dual-module.js
  var Q = require('q');
  
  module.exports = {
    getFullName: function (firstName, lastName, callback) {
      var deferred = Q.defer();
  
      if (firstName &amp;&amp; lastName) {
          var fullName = firstName + " " + lastName;
          deferred.resolve(fullName);
      }
      else {
          deferred.reject("First and last name must be passed.");
      }
  
      deferred.promise.nodeify(callback);
      return deferred.promise;
   }
  }
  </code></pre>
  
  <p>```</p>
  
  <pre><code>var DualModule = require('dual-module');
  
  DualModule.getFullName("John", "Doe")
  .then(function (result) {
      // result returns "John Doe"
  })
  .fail(function (error) {
      // error returns error message if either first or last name are null or undefined
  });
  
  
  var DualModule = require('dual-module');
  
  DualModule.getFullName("John", "Doe", function (error, result) {
      // error returns error message if either first or last name are null or undefined   
      // result returns "John Doe"
  });
  </code></pre>