Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-alpha.8/dist/global/Rx.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
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 => 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 => console.log('custom ' + value)) 
  .subscribe();
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers