nice-ui
Version:
React design system, components, and utilities
25 lines (24 loc) • 778 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToastStack = void 0;
const rxjs_1 = require("rxjs");
const ToastItem_1 = require("./ToastItem");
class ToastStack {
constructor() {
this.stack$ = new rxjs_1.BehaviorSubject([]);
this.add = (opts) => {
const item = new ToastItem_1.ToastItem(this, opts);
this.stack$.next([...this.stack$.getValue(), item]);
return item;
};
this.remove = (item) => {
const stack = this.stack$.getValue();
const index = stack.indexOf(item);
if (index < 0)
return;
stack.splice(index, 1);
this.stack$.next(stack);
};
}
}
exports.ToastStack = ToastStack;
;