title: Convert promise in angular 1 to observable in angular 2
body: <p>i'm still learning observable in angular 2, and has not been able to figure out how to convert my code in angular 1 to angular 2.</p>
  
  <pre><code>function promiseFunc() {
    var deferred = $q.defer();      
  
    $http.post(url, something)
      .then(function (response) {
        if (response === 1) deferred.resolve(response.data);
        else deferred.reject();
      }).catch(function (e) {
        deferred.reject(e);
      });
  
    return deferred.promise;
  }    
  </code></pre>
  
  <p>Can anyone tell me how i can convert this code with angular 2 observable?</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>And what if the http.post is optional?</p>
  
  <pre><code>function promiseFunc(param1) {
    var deferred = $q.defer();      
  
    if (param1 === 1) {
      deferred.resolve(1);
    } else {
      $http.post(url, something)
        .then(function (response) {
          if (response.x === 1) deferred.resolve(response);
          else deferred.reject();
        }).catch(function (e) {
          deferred.reject(e);
        });
    }
  
    return deferred.promise;
  }
  </code></pre>
  
  <p>What i'm missing in observable is the ability to call resolve and reject. Can it be done in observable?</p>