take - 2

RxJS 5 take

HTML

<script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.umd.js"></script>
<div id="locationDisplay">
  Where would you click first?
</div>

JavaScript

const oneClickEvent = Rx.Observable
	.fromEvent(document, 'click')
  .take(5)
  .do(v => {
  	document.getElementById('locationDisplay').innerHTML
    	= `Your first click was on location ${v.screenX}:${v.screenY}`;
  });

const subscribe = oneClickEvent.subscribe();