title: What is the difference between Observable.lift and Observable.pipe in rxjs?
body: <p><a href="http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html" rel="noreferrer">The docs</a> define <code>Observable.lift(operator: Operator)</code> as:</p>
  
  <blockquote>
    <p>Creates a new Observable, with this Observable as the source, and the
    passed operator defined as the new observable's operator.</p>
  </blockquote>
  
  <p>and <code>Observable.pipe(operations: ...*)</code> as:</p>
  
  <blockquote>
    <p>Used to stitch together functional operators into a chain. Returns the
    Observable result of all of the operators having been called in the
    order they were passed in.</p>
  </blockquote>
  
  <p>So clearly <code>.pipe</code> can accept multiple operators, which <code>.lift</code> cannot. But <code>pipe</code> can also accept a single operator, so this cannot be the only difference. From the docs alone it isn't clear to me what they are both for and why they exist. <strong>Can someone please explain the purpose of each of these functions, and when each of them should be used?</strong></p>
  
  <hr>
  
  <h3>Observations so far</h3>
  
  <p>The following code (typescript):</p>
  
  <pre><code>let myObservable = Observable.of(1, 2, 3);
  let timesByTwoPiped = myObservable.pipe(map(n =&gt; n * 2));
  let timesByTwoLift = myObservable.lift(new TimesByTwoOperator());
  
  timesByTwoPiped.subscribe(a =&gt; console.log('pipe:' + a));
  timesByTwoLift.subscribe(a =&gt; console.log('lift:' + a));
  </code></pre>
  
  <p>and <code>TimesByTwoOperator</code>:</p>
  
  <pre><code>class TimesByTwoOperator implements Operator&lt;number, number&gt; {
    call(subscriber: Subscriber&lt;number&gt;, source: Observable&lt;number&gt;): void | Function | AnonymousSubscription {
      source.subscribe(n =&gt; {
        subscriber.next(n * 2);
      });
    }
  }
  </code></pre>
  
  <p>Seems to achieve the same result using both <code>.lift</code> and <code>.pipe</code>. This experiment shows I'm correct in thinking that both lift and pipe can be used to achieve the same thing, albeit with the pipe version being more succinct in this case.</p>
  
  <p>As the <code>Operator</code> type that is passed in to <code>.lift</code> is given full access to the source observable and subscriptions, clearly powerful things could be achieved with it; for example keeping state. But I'm aware that the same sort of power can also be achieved with <code>.pipe</code>, for example with the <a href="https://www.learnrxjs.io/operators/transformation/buffer.html" rel="noreferrer"><code>buffer</code> operator</a>.</p>
  
  <p>It's still not clear to me why they both exist and what each is designed for.</p>