Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[forkjoin]">
  <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>
<input id="inputA" placeholder="Field A" type="text"><button id="A">A</button>
  <input id="inputB" placeholder="Field B" type="text"><button id="B">B</button>
<button id="end">end</button>
  <ol>
    <li>Enter a value for Field A and then click Button A to register value</li>
    <li>Enter a value for Field B and then click Button B to register value</li>
    <li>Click end button when both field are registered</li>
    
  </body>
</html>
 
const getValue = (id) => document.getElementById(`input${id}`).value
const clickEvent = (id) => Rx.Observable
                             .fromEvent(
                                 document.getElementById(id),'click', ()=> getValue(id)
                             ).takeUntil(unsubscribe)
const unsubscribe = Rx.Observable
                    .fromEvent(
                      document.getElementById("end"),'click'
                    )
const streamA = clickEvent('A');
const streamB = clickEvent('B');
const forkJoin = Rx.Observable.forkJoin(streamA, streamB)
              .subscribe(
                forkJoin => console.log('forkJoin', forkJoin)
              )
Output

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

Dismiss x
public
Bin info
kkennethleepro
0viewers