UNPKG

dap-design-system

Version:

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

32 lines (31 loc) 1.24 kB
import { ContextRequestEvent as o } from "../context-request-event.js"; /** * @license * Copyright 2021 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ class n { constructor(c, t, b, i) { var h; if (this.subscribe = !1, this.provided = !1, this.value = void 0, this.t = (s, e) => { this.unsubscribe && (this.unsubscribe !== e && (this.provided = !1, this.unsubscribe()), this.subscribe || this.unsubscribe()), this.value = s, this.host.requestUpdate(), this.provided && !this.subscribe || (this.provided = !0, this.callback && this.callback(s, e)), this.unsubscribe = e; }, this.host = c, t.context !== void 0) { const s = t; this.context = s.context, this.callback = s.callback, this.subscribe = (h = s.subscribe) != null ? h : !1; } else this.context = t, this.callback = b, this.subscribe = i != null ? i : !1; this.host.addController(this); } hostConnected() { this.dispatchRequest(); } hostDisconnected() { this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0); } dispatchRequest() { this.host.dispatchEvent(new o(this.context, this.host, this.t, this.subscribe)); } } export { n as ContextConsumer }; //# sourceMappingURL=context-consumer.js.map