Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/@reactivex/rxjs@5.0.0-rc.5/dist/global/Rx.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
const Observable = Rx.Observable;
const BehaviorSubject = Rx.BehaviorSubject;
const Subject = Rx.Subject;
var routes$ = new BehaviorSubject(['default']);
routes$.switchMap((arr) => {
    return Observable.interval(200)
        .take(arr.length)
        .map(i => arr[i])
        .timeInterval()
        .do(null, null, () => console.log('Complete'));
}).subscribe(value => {
    console.log(value);
});
routes$.next(['left', 'top', 'left']);
setTimeout(() => {
    routes$.next(['top', 'right', 'down']);
}, 1000);
Output

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

Dismiss x
public
Bin info
martinsikpro
0viewers