ng2-events
Version:
Supercharge your Angular2+ event handling
45 lines (44 loc) • 1.4 kB
TypeScript
import { Renderer2, ElementRef, NgZone, OnDestroy } from "@angular/core";
import { Subject } from "rxjs";
import * as i0 from "@angular/core";
/**
* Pass events to a given observable subject without triggering change detection
*
* Usage:
* <button [ev-observe]="subject" ev-events="click"></button>
*
* ...
*
* export class ExampleComponent implements OnInit {
* public subject = new Subject();
*
* constructor(private zone: NgZone) {}
*
* ngOnInit() {
* this.subject
* .throttleTime(300)
* .filter(someCondition)
* ...
* .subscribe($event => this.zone.run(() => this.handleEvent($event)));
* }
* }
*
* Notes:
* The [ev-events] property can be either a string or an array of strings to handle multiple events
*
*/
export declare class ObserveEventDirective implements OnDestroy {
private elm;
private renderer;
private zone;
observe: Subject<any>;
set events(e: string | string[]);
private listeners;
constructor(elm: ElementRef, renderer: Renderer2, zone: NgZone);
ngOnDestroy(): void;
private unregisterAll;
private addListener;
private fireEvent;
static ɵfac: i0.ɵɵFactoryDeclaration<ObserveEventDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<ObserveEventDirective, "[ev-observe]", never, { "observe": "ev-observe"; "events": "ev-events"; }, {}, never>;
}