Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>RxJS</title>
  <script src="https://unpkg.com/@reactivex/rxjs@5.0.2/dist/global/Rx.js"></script>
</head>
<body>
</body>
</html>
 
console.clear();
Rx.Observable.prototype.handleFn = function (fn) {
    const source = this;
    return Rx.Observable.create(function (obs) {
        return source.subscribe(function(val){
            obs.next(fn.call(obs,val));
        });
    });
};
const obs = Rx.Observable.interval(1000)
    .handleFn(function(){
        return Rx.Observable.timer(150).mapTo(Math.random());
    })
    .mergeAll();
obs.subscribe(x => console.log(x))
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers