Skip to content

Instantly share code, notes, and snippets.

@jdjuan
Created February 21, 2018 19:04
Show Gist options
  • Save jdjuan/cc0532315881c220e4640a8a27b725f7 to your computer and use it in GitHub Desktop.
Save jdjuan/cc0532315881c220e4640a8a27b725f7 to your computer and use it in GitHub Desktop.
import { paint } from './canvas.js';
const { fromEvent } = Rx.Observable;
const { takeUntil, mergeMap } = Rx.operators;
const move$ = fromEvent(document, 'mousemove')
const down$ = fromEvent(document, 'mousedown')
const up$ = fromEvent(document, 'mouseup')
const paints$ = down$.pipe(
mergeMap(down => move$.pipe(takeUntil(up$)))
);
paints$.subscribe(paint);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment