UNPKG

@ng-doc/ui-kit

Version:

<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>

49 lines (45 loc) 2.21 kB
import * as i0 from '@angular/core'; import { inject, Injectable } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { notificationCloseAnimation, notificationOpenAnimation } from '@ng-doc/ui-kit/animations'; import { NgDocOverlayContainerComponent } from '@ng-doc/ui-kit/components/overlay-container'; import { NgDocOverlayService } from '@ng-doc/ui-kit/services/overlay'; import { Subject, timer } from 'rxjs'; import { tap, switchMap } from 'rxjs/operators'; class NgDocNotifyService { constructor() { this.overlayService = inject(NgDocOverlayService); this.notify$ = new Subject(); this.notify$ .pipe(tap(() => this.overlayRef?.close()), tap((content) => this.openOverlay(content)), switchMap(() => timer(2000)), takeUntilDestroyed()) .subscribe(() => this.overlayRef?.close()); } notify(content) { this.notify$.next(content); } openOverlay(content) { this.overlayRef = this.overlayService.open(content, { overlayContainer: NgDocOverlayContainerComponent, panelClass: 'ng-doc-notify', positionStrategy: this.overlayService .globalPositionStrategy() .bottom('10px') .centerHorizontally(), openAnimation: notificationOpenAnimation, closeAnimation: notificationCloseAnimation, }); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgDocNotifyService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgDocNotifyService, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.3", ngImport: i0, type: NgDocNotifyService, decorators: [{ type: Injectable, args: [{ providedIn: 'root', }] }], ctorParameters: () => [] }); /** * Generated bundle index. Do not edit. */ export { NgDocNotifyService }; //# sourceMappingURL=ng-doc-ui-kit-services-notify.mjs.map