title: RxJS 5 subclassing Observable - static methods return instances of the parent class
body: <p>I'm trying to subclass the RxJS Observable class as described <a href="https://github.com/ReactiveX/RxJS/blob/master/doc/operator-creation.md" rel="nofollow">here</a> by subclassing Observable and overriding the lift method. </p>
  
  <p>This works for any operators I add to the prototype, but whenever I try to instantiate a new Observable of my subclass (e.g. using MyObservable.from([1, 2, 3]), I get an Observable of the parent class. </p>
  
  <p>How do I subclass Observable correctly, so that using Observable.return / Observable.from / works as expected? <a href="http://jsbin.com/yecayosuko/edit?js,console" rel="nofollow">jsbin</a></p>
  
  <pre><code>class MyObservable extends Rx.Observable {
    lift(operator) {
      const observable = new MyObservable();
      observable.source = this;
      observable.operator = operator;
      return observable;
    }
  
    customOperator() {
      return this.map(arguments)
    }
  }
  
  
  // instantiating an observable with **MyObservable**.from
  var observable = MyObservable.from([1, 2, 3]);
  console.log('instance of Rx.Observable: ' + observable instanceof Rx.Observable);
  
  
  // this works as map is defined on RxObservable
  observable
    .map(value =&gt; console.log('standard ' + value)) 
    .subscribe();
  
  
  // this doesn't work. customOperator is only defined on MyObservable
  // and MyObservable.from([1, 2, 3]) returns an Rx.Observable instance
  observable
    .customOperator(value =&gt; console.log('custom ' + value)) 
    .subscribe();    
  </code></pre>