Skip to content

Instantly share code, notes, and snippets.

@pramoth
Created September 2, 2018 16:58
Show Gist options
  • Select an option

  • Save pramoth/80e5be10d1598c2de14d7878a60d4539 to your computer and use it in GitHub Desktop.

Select an option

Save pramoth/80e5be10d1598c2de14d7878a60d4539 to your computer and use it in GitHub Desktop.
export class AppComponent implements OnDestroy {
private _onDestroy = new Subject<void>();
constructor(@Inject(DOCUMENT) document: any) {
fromEvent(document, 'mousedown').pipe(takeUntil(this._onDestroy))
.subscribe(() => { /*...*/ }));
fromEvent(document, 'mouseup').pipe(takeUntil(this._onDestroy))
.subscribe(() => { /*...*/ }));
fromEvent(document, 'mousemove').pipe(takeUntil(this._onDestroy))
.subscribe(() => { /*...*/ }));
}
ngOnDestroy(): void {
this._onDestroy.next();
this._onDestroy.complete();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment