ng2-idle-core
Version:
ng-idle for Angular 2+ core module
59 lines • 2.01 kB
JavaScript
import { EventEmitter } from '@angular/core';
/*
* A base for classes that act as a source for interrupts.
*/
var /*
* A base for classes that act as a source for interrupts.
*/
InterruptSource = /** @class */ (function () {
function InterruptSource(attachFn, detachFn) {
this.attachFn = attachFn;
this.detachFn = detachFn;
this.isAttached = false;
this.onInterrupt = new EventEmitter();
}
/*
* Attaches to the specified events on the specified source.
*/
/*
* Attaches to the specified events on the specified source.
*/
InterruptSource.prototype.attach = /*
* Attaches to the specified events on the specified source.
*/
function () {
var _this = this;
// If the current zone is the 'angular' zone (a.k.a. NgZone) then re-enter this method in its parent zone
// The parent zone is usually the '<root>' zone but it can also be 'long-stack-trace-zone' in debug mode
// In tests, the current zone is typically a 'ProxyZone' created by async/fakeAsync (from @angular/core/testing)
if (Zone.current.get('isAngularZone') === true) {
Zone.current.parent.run(function () { return _this.attach(); });
return;
}
if (!this.isAttached && this.attachFn) {
this.attachFn(this);
}
this.isAttached = true;
};
/*
* Detaches from the specified events on the specified source.
*/
/*
* Detaches from the specified events on the specified source.
*/
InterruptSource.prototype.detach = /*
* Detaches from the specified events on the specified source.
*/
function () {
if (this.isAttached && this.detachFn) {
this.detachFn(this);
}
this.isAttached = false;
};
return InterruptSource;
}());
/*
* A base for classes that act as a source for interrupts.
*/
export { InterruptSource };
//# sourceMappingURL=interruptsource.js.map