Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<button id="increment">increment</button>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/5.4.0/Rx.js"></script>
 
const increment = document.getElementById('increment');
Rx.Observable.fromEvent(increment, 'click')
  .mapTo(1)
  .subscribe(
    x => console.log(`next: ${x}`),
    error => console.error(`error: ${error}`),
    () => console.log('complete')
  );
// button をクリックする度に以下がコンソール出力される。
// => "next: 1"
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers