Skip to content

Instantly share code, notes, and snippets.

@jdjuan
Created February 21, 2018 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdjuan/0fdce7209a838f0baa1140f1d6b296b6 to your computer and use it in GitHub Desktop.
Save jdjuan/0fdce7209a838f0baa1140f1d6b296b6 to your computer and use it in GitHub Desktop.
import { paint } from './canvas.js';
const { fromEvent } = Rx.Observable;
const { skipUntil, takeUntil, repeat } = Rx.operators;
const move$ = fromEvent(document, 'mousemove');
const down$ = fromEvent(document, 'mousedown')
const up$ = fromEvent(document, 'mouseup')
const paints$ = move$.pipe(
skipUntil(down$),
takeUntil(up$),
repeat()
);
paints$.subscribe(paint);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment