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 5 Operators</title>
  <script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-beta.8/dist/global/Rx.umd.js"></script>
</head>
<body>
</body>
</html>
 
const firstInterval = Rx.Observable.interval(1000).take(10);
const secondInterval = Rx.Observable.interval(1000).take(2);
const exhaustSub = firstInterval
.exhaustMap(f => {
  console.log(`Emission of first interval: ${f}`);
  return secondInterval;
})
/*
    When we subscribed to the first interval, it starts to emit a values (startinng 0).
    This value is mapped to the second interval which then begins to emit (starting 0).  
    While the second interval is active, values from the first interval are ignored.
    We can see this when firstInterval emits number 3,6, and so on...
  
    Output:
    Emission of first interval: 0
    0
    1
    Emission of first interval: 3
    0
    1
    Emission of first interval: 6
    0
    1
    Emission of first interval: 9
    0
    1
*/
.subscribe(s => console.log(s));
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers