@wellwind/ngx-thanos
Version:
Use [Thanos](https://www.google.com/search?q=Thanos) snap to destory your DOM elements on Angular.
134 lines (127 loc) • 3.87 kB
JavaScript
import { CommonModule } from '@angular/common';
import { Injectable, Directive, ElementRef, EventEmitter, Input, Output, NgModule, defineInjectable } from '@angular/core';
import { thanosRewind, thanosSnap } from '@wellwind/thanos-snap';
import { from } from 'rxjs';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class ThanosSnapService {
constructor() { }
/**
* @param {?} target
* @return {?}
*/
snap(target) {
return from(thanosSnap(target));
}
/**
* @param {?} target
* @return {?}
*/
rewind(target) {
return from(thanosRewind(target));
}
}
ThanosSnapService.decorators = [
{ type: Injectable, args: [{
providedIn: 'root'
},] }
];
/** @nocollapse */
ThanosSnapService.ctorParameters = () => [];
/** @nocollapse */ ThanosSnapService.ngInjectableDef = defineInjectable({ factory: function ThanosSnapService_Factory() { return new ThanosSnapService(); }, token: ThanosSnapService, providedIn: "root" });
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class ThanosSnapDirective {
/**
* @param {?} elementRef
* @param {?} thanosSnapService
*/
constructor(elementRef, thanosSnapService) {
this.elementRef = elementRef;
this.thanosSnapService = thanosSnapService;
this.ngxThanosSnap = false;
this.snapStarting = new EventEmitter();
this.snapEnded = new EventEmitter();
this.rewinded = new EventEmitter();
}
/**
* @return {?}
*/
get host() {
return this.elementRef.nativeElement;
}
/**
* @return {?}
*/
ngOnChanges() {
if (this.ngxThanosSnap) {
this.snap();
}
else {
this.rewind();
}
}
/**
* @return {?}
*/
snap() {
this.snapStarting.emit();
this.thanosSnapService.snap(this.host).subscribe((/**
* @return {?}
*/
() => this.snapEnded.emit()));
}
/**
* @return {?}
*/
rewind() {
this.thanosSnapService.rewind(this.host).subscribe((/**
* @return {?}
*/
() => this.rewinded.emit()));
}
}
ThanosSnapDirective.decorators = [
{ type: Directive, args: [{
selector: '[ngxThanosSnap]',
exportAs: 'ngxThanosSnap'
},] }
];
/** @nocollapse */
ThanosSnapDirective.ctorParameters = () => [
{ type: ElementRef },
{ type: ThanosSnapService }
];
ThanosSnapDirective.propDecorators = {
ngxThanosSnap: [{ type: Input }],
snapStarting: [{ type: Output }],
snapEnded: [{ type: Output }],
rewinded: [{ type: Output }]
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class NgxThanosModule {
}
NgxThanosModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule],
declarations: [ThanosSnapDirective],
exports: [ThanosSnapDirective]
},] }
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { NgxThanosModule, ThanosSnapDirective, ThanosSnapService };
//# sourceMappingURL=wellwind-ngx-thanos.js.map