UNPKG

@nent/core

Version:

Functional elements to add routing, data-binding, dynamic HTML, declarative actions, audio, video, and so much more. Supercharge static HTML files into web apps without script or builds.

4 lines 1.48 kB
/*! * NENT 2022 */ import{r as s,h as t,H as i}from"./index-916ca544.js";import{a,e as r}from"./index-f7016b94.js";import{f as o}from"./logging-5a93c8af.js";import{a as e}from"./state-27a8a5bc.js";import{a as n,s as c,c as d}from"./factory-acbf0d3d.js";import{a as m,D as l}from"./interfaces-8c5cd1b8.js";import{D as h}from"./interfaces-4b724211.js";import"./index-4bfabbbd.js";import"./values-ddfac998.js";import"./promises-584c4ece.js";class f{constructor(){this.disposeHandles=[]}initialize(s,t,i){this.eventBus=i;const a=t.on(m,(s=>{this.handleAction(s)}));this.disposeHandles.push(a)}registerProvider(s,t){var i;const a=null===(i=t.changed)||void 0===i?void 0:i.on("*",(()=>{o(e.debug,`data-provider: ${s} changed`),this.eventBus.emit(l.DataChanged,{provider:s})}));a&&this.disposeHandles.push(a),n(s,t)}async handleAction(s){if(o(e.debug,`data-listener: action received {command:${s.command}}`),s.command===h.RegisterDataProvider){const{name:t,provider:i}=s.data;t&&i&&this.registerProvider(t,i)}}destroy(){this.disposeHandles.forEach((s=>null==s?void 0:s.call(this)))}}const p=class{constructor(t){s(this,t),this.debug=!1}componentWillLoad(){o(this.debug,"n-data: registering data listener"),this.debug&&(c.debug=!0),this.listener=new f,e.dataEnabled=!0,this.providerTimeout&&(c.providerTimeout=this.providerTimeout),this.listener.initialize(window,a,r)}render(){return t(i,null,t("slot",null))}disconnectedCallback(){this.listener.destroy(),d()}};export{p as n_data}