JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://unpkg.com/@reactivex/rxjs@5.2.0/dist/global/Rx.js"></script>
<h1>按著我,看 console</h1>

CSS

html, body {
  height: 100%;
  background-color: tomato;
}

JavaScript

var source = Rx.Observable.interval(1000);
var mouseDown = Rx.Observable.fromEvent(document, 'mousedown');
var mouseUp = Rx.Observable.fromEvent(document, 'mouseup');

var example = source
  .windowToggle(mouseDown, () => mouseUp)
  .switch();
  
example.subscribe(console.log);