Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/2.3.22/rx.all.js"></script>
<script src="//code.jquery.com/jquery-2.1.0.min.js"></script>
  <title>JS Bin</title>
  <script src="//cdn.jsdelivr.net/rsvp/3.0.6/rsvp.js"></script>
</head>
<body>
  <input id="input" type="text">
</body>
</html>
 
function SampleObserver () {
    Rx.Observer.call(this);
    this.isStopped = false;
}
SampleObserver.prototype = Object.create(Rx.Observer.prototype);
SampleObserver.prototype.constructor = SampleObserver;
Object.defineProperties(SampleObserver.prototype, {
    onNext: {
        value: x => {
            if (!this.isStopped) {
                console.log(`Next: ${x}`);
            }
        }
    },
    onError: {
        value: err => {
            if (!this.isStopped) {
                this.isStopped = true;
                console.log(`Error: ${err}`);
            }
        }
    },
    onCompleted: {
        value: () => {
            if (!this.isStopped) {
                this.isStopped = true;
                console.log('Completed');
            }
        }
    } 
});
var sampleObserver = new SampleObserver();
var source = sampleObserver.asObserver();
console.log(source === sampleObserver);
// => false
Output

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

Dismiss x
public
Bin info
dstoyanovpro
0viewers