UNPKG

dap-design-system

Version:

Official design system for the DÁP (dap.gov.hu)

38 lines (37 loc) 941 B
/** * @license * Copyright 2021 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ class r { get value() { return this.o; } set value(s) { this.setValue(s); } setValue(s, t = !1) { const i = t || !Object.is(s, this.o); this.o = s, i && this.updateObservers(); } constructor(s) { this.subscriptions = /* @__PURE__ */ new Map(), this.updateObservers = () => { for (const [t, { disposer: i }] of this.subscriptions) t(this.o, i); }, s !== void 0 && (this.value = s); } addCallback(s, t, i) { if (!i) return void s(this.value); this.subscriptions.has(s) || this.subscriptions.set(s, { disposer: () => { this.subscriptions.delete(s); }, consumerHost: t }); const { disposer: e } = this.subscriptions.get(s); s(this.value, e); } clearCallbacks() { this.subscriptions.clear(); } } export { r as ValueNotifier }; //# sourceMappingURL=value-notifier.js.map