UNPKG

ng2-events

Version:

Supercharge your Angular2+ event handling

71 lines (70 loc) 3.02 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.UndetectedEventPlugin = void 0; var core_1 = require("@angular/core"); var common_1 = require("@angular/common"); var event_manager_plugin_1 = require("../__util/event-manager-plugin"); var i0 = require("@angular/core"); /** * Listen to events without triggering change detection * * Usage: * <button (undetected.click)="handleClick()"></button> * * ... * * export class ExampleComponent implements OnInit { * * constructor(private zone: NgZone) {} * * handleClick() { * if(someCondition) { * this.zone.run(() => { * ... * }); * } * } * } * */ var UndetectedEventPlugin = /** @class */ (function (_super) { __extends(UndetectedEventPlugin, _super); function UndetectedEventPlugin(doc) { return _super.call(this, doc) || this; } UndetectedEventPlugin.prototype.supports = function (eventName) { return eventName.indexOf('undetected.') === 0; }; UndetectedEventPlugin.prototype.addEventListener = function (element, eventName, handler) { var _this = this; var realEventName = eventName.slice(11); return this.manager.getZone().runOutsideAngular(function () { return _this.manager.addEventListener(element, realEventName, handler); }); }; UndetectedEventPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.2", ngImport: i0, type: UndetectedEventPlugin, deps: [{ token: common_1.DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); UndetectedEventPlugin.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.0.2", ngImport: i0, type: UndetectedEventPlugin }); return UndetectedEventPlugin; }(event_manager_plugin_1.MyEventManagerPlugin)); exports.UndetectedEventPlugin = UndetectedEventPlugin; i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.2", ngImport: i0, type: UndetectedEventPlugin, decorators: [{ type: core_1.Injectable }], ctorParameters: function () { return [{ type: undefined, decorators: [{ type: core_1.Inject, args: [common_1.DOCUMENT] }] }]; } });