Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.0.min.js"></script>
  <title>JS Bin</title>
  <script src="//cdnjs.cloudflare.com/ajax/libs/rxjs/2.2.28/rx.all.min.js"></script>
</head>
<body>
  <input id="input1" type="text">
  <input id="input2" type="text">
</body>
</html>
 
var input1 = $('#input1');
var input2 = $('#input2');
var source = Rx.Observable.amb(
  Rx.Observable.fromEvent(input1, 'click').map(()=>'one'),
  Rx.Observable.fromEvent(input2, 'click').map(()=>'two')
);
var subscription = source.subscribe(
    function (x) {
        console.log(x);
    },
    function (err) {
        console.log('Error: ' + err);   
    },
    function () {
        console.log('Completed');   
    });
Output

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

Dismiss x
public
Bin info
caolixiangpro
0viewers