UNPKG

689 BJavaScriptView Raw
1import { r as registerInstance, g as getElement } from './stencilrouter-1307249c.js';
2
3class ContextConsumer {
4 constructor(hostRef) {
5 registerInstance(this, hostRef);
6 this.context = {};
7 this.renderer = () => null;
8 }
9 connectedCallback() {
10 if (this.subscribe != null) {
11 this.unsubscribe = this.subscribe(this.el, 'context');
12 }
13 }
14 disconnectedCallback() {
15 if (this.unsubscribe != null) {
16 this.unsubscribe();
17 }
18 }
19 render() {
20 return this.renderer(Object.assign({}, this.context));
21 }
22 get el() { return getElement(this); }
23}
24
25export { ContextConsumer as context_consumer };