.DS_Store
# save-time-avoiding-common-mistakes-using-rxjs
#dotElem {
  position: absolute;
  width: 10px;
  height: 10px;
  left: 0;
  top: 0;
  border-radius: 5px;
  background-color: red;
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <link rel="stylesheet" href="app.css">
</head>
<body>
  <div id="dotElem"></div>
	<script src="https://unpkg.com/rxjs@5.4.3/bundles/Rx.min.js"></script>
	<script src="script.js"></script>
</body>
</html>
function updateDot(x, y) {
  dotElem.style.left = `${x}px`;
  dotElem.style.top = `${y}px`;
}

const click$ = Rx.Observable.fromEvent(document, 'click');

click$.subscribe(ev => updateDot(ev.clientX, ev.clientY));

const res$ = click$
  .switchMap(ev => Rx.Observable.ajax({
    url: 'https://jsonplaceholder.typicode.com/users/1',
    method: 'GET',
  }));

res$.subscribe(function (data) {
  console.log(data.response) || displayInPreview(data.response);
});




// display in plunker preview
function displayInPreview(string) {
  var newDiv = document.createElement("div"); 
  var newContent = document.createTextNode(string); 
  newDiv.appendChild(newContent);
  document.body.appendChild(newDiv)
}