Icard/angular-clarity-master(work.../node_modules/ngx-toastr/esm2022/toastr/toast-ref.mjs

75 lines
7.8 KiB
JavaScript
Raw Normal View History

2024-07-16 14:55:36 +00:00
import { Subject } from 'rxjs';
/**
* Reference to a toast opened via the Toastr service.
*/
export class ToastRef {
_overlayRef;
/** The instance of component opened into the toast. */
componentInstance;
/** Count of duplicates of this toast */
duplicatesCount = 0;
/** Subject for notifying the user that the toast has finished closing. */
_afterClosed = new Subject();
/** triggered when toast is activated */
_activate = new Subject();
/** notifies the toast that it should close before the timeout */
_manualClose = new Subject();
/** notifies the toast that it should reset the timeouts */
_resetTimeout = new Subject();
/** notifies the toast that it should count a duplicate toast */
_countDuplicate = new Subject();
constructor(_overlayRef) {
this._overlayRef = _overlayRef;
}
manualClose() {
this._manualClose.next();
this._manualClose.complete();
}
manualClosed() {
return this._manualClose.asObservable();
}
timeoutReset() {
return this._resetTimeout.asObservable();
}
countDuplicate() {
return this._countDuplicate.asObservable();
}
/**
* Close the toast.
*/
close() {
this._overlayRef.detach();
this._afterClosed.next();
this._manualClose.next();
this._afterClosed.complete();
this._manualClose.complete();
this._activate.complete();
this._resetTimeout.complete();
this._countDuplicate.complete();
}
/** Gets an observable that is notified when the toast is finished closing. */
afterClosed() {
return this._afterClosed.asObservable();
}
isInactive() {
return this._activate.isStopped;
}
activate() {
this._activate.next();
this._activate.complete();
}
/** Gets an observable that is notified when the toast has started opening. */
afterActivate() {
return this._activate.asObservable();
}
/** Reset the toast timouts and count duplicates */
onDuplicate(resetTimeout, countDuplicate) {
if (resetTimeout) {
this._resetTimeout.next();
}
if (countDuplicate) {
this._countDuplicate.next(++this.duplicatesCount);
}
}
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9hc3QtcmVmLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2xpYi90b2FzdHIvdG9hc3QtcmVmLnRzIl0sIm5hbWVzIjpbXSwibW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