aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/utilities/debounce-click.directive.ts
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-04-13 15:47:40 +0800
committerGitHub <noreply@github.com>2019-04-13 15:47:40 +0800
commit56c51bdf844ce1e3642dcdc4099187e7e57008c7 (patch)
tree1aa37565aad734b604eb94ed3a62db2308f4b30d /Timeline/ClientApp/src/app/utilities/debounce-click.directive.ts
parent19cae15eba2bcede41b818e1b8ab7fd5ac92eb05 (diff)
parent108ea333534445a8c76d4db632ebf21abf426c71 (diff)
downloadtimeline-56c51bdf844ce1e3642dcdc4099187e7e57008c7.tar.gz
timeline-56c51bdf844ce1e3642dcdc4099187e7e57008c7.tar.bz2
timeline-56c51bdf844ce1e3642dcdc4099187e7e57008c7.zip
Merge pull request #20 from crupest/separate
Separate front end and back end.
Diffstat (limited to 'Timeline/ClientApp/src/app/utilities/debounce-click.directive.ts')
-rw-r--r--Timeline/ClientApp/src/app/utilities/debounce-click.directive.ts41
1 files changed, 0 insertions, 41 deletions
diff --git a/Timeline/ClientApp/src/app/utilities/debounce-click.directive.ts b/Timeline/ClientApp/src/app/utilities/debounce-click.directive.ts
deleted file mode 100644
index 1d01b671..00000000
--- a/Timeline/ClientApp/src/app/utilities/debounce-click.directive.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { Directive, Output, Input, EventEmitter, ElementRef, OnInit, OnDestroy } from '@angular/core';
-import { fromEvent, Subscription } from 'rxjs';
-import { debounceTime } from 'rxjs/operators';
-
-@Directive({
- selector: '[appDebounceClick]'
-})
-export class DebounceClickDirective implements OnInit, OnDestroy {
-
- private subscription: Subscription | undefined;
-
- @Output('appDebounceClick') clickEvent = new EventEmitter<any>();
-
- // tslint:disable-next-line:no-input-rename
- @Input('appDebounceClickTime')
- set debounceTime(value: number) {
- if (this.subscription) {
- this.subscription.unsubscribe();
- }
- this.subscription = fromEvent(<HTMLElement>this.element.nativeElement, 'click').pipe(
- debounceTime(value)
- ).subscribe(o => this.clickEvent.emit(o));
- }
-
- constructor(private element: ElementRef) {
- }
-
- ngOnInit() {
- if (!this.subscription) {
- this.subscription = fromEvent(<HTMLElement>this.element.nativeElement, 'click').pipe(
- debounceTime(500)
- ).subscribe(o => this.clickEvent.emit(o));
- }
- }
-
- ngOnDestroy() {
- if (this.subscription) {
- this.subscription.unsubscribe();
- }
- }
-}