plastikaweb
7/21/2017 - 10:48 AM

JS Bin combineLatest // source https://jsbin.com/xilojuf

JS Bin

combineLatest

// source https://jsbin.com/xilojuf

<!DOCTYPE html>
<html>
<head>
<meta name="description" content="combineLatest">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <script src="https://unpkg.com/@reactivex/rxjs@5.0.3/dist/global/Rx.js"></script>
</head>
<body>

<script id="jsbin-javascript">
const streamA = Rx.Observable.interval(300).take(6);
const streamB = Rx.Observable.interval(500).take(4);
console.log('init');
// stream A ---0---1---2---3---4---5-->
// stream B -----0-----1-----2-----3-->
// output   ---0---1---2---3---4---5--(1,2,3,4)-|->

const streamOutput = Rx.Observable.combineLatest(
  streamA, streamB, (a, b) => {
    return a + b;
  });

streamOutput.subscribe(console.log);
</script>

<script id="jsbin-source-html" type="text/html">
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="combineLatest">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <script src="https://unpkg.com/@reactivex/rxjs@5.0.3/dist/global/Rx.js"><\/script>
</head>
<body>

</body>
</html></script>


<script id="jsbin-source-javascript" type="text/javascript">const streamA = Rx.Observable.interval(300).take(6);
const streamB = Rx.Observable.interval(500).take(4);
console.log('init');
// stream A ---0---1---2---3---4---5-->
// stream B -----0-----1-----2-----3-->
// output   ---0---1---2---3---4---5--(1,2,3,4)-|->

const streamOutput = Rx.Observable.combineLatest(
  streamA, streamB, (a, b) => {
    return a + b;
  });

streamOutput.subscribe(console.log);
</script></body>
</html>
const streamA = Rx.Observable.interval(300).take(6);
const streamB = Rx.Observable.interval(500).take(4);
console.log('init');
// stream A ---0---1---2---3---4---5-->
// stream B -----0-----1-----2-----3-->
// output   ---0---1---2---3---4---5--(1,2,3,4)-|->

const streamOutput = Rx.Observable.combineLatest(
  streamA, streamB, (a, b) => {
    return a + b;
  });

streamOutput.subscribe(console.log);