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.3 kB
/*! * NENT 2022 */ import{r as s,a as t}from"./index-916ca544.js";import{a as i,e as r}from"./index-f7016b94.js";import{a,r as o}from"./factory-acbf0d3d.js";import{D as e}from"./interfaces-4b724211.js";import{D as n}from"./interfaces-8c5cd1b8.js";import"./index-4bfabbbd.js";import"./values-ddfac998.js";import"./promises-584c4ece.js";import"./logging-5a93c8af.js";class c{constructor(s,t,i,r=""){this.eventBus=t,this.name=i,this.prefix=r,this.sessionStorage=s.sessionStorage}async get(s){var t;return null===(t=this.sessionStorage)||void 0===t?void 0:t.getItem(this.prefix+s)}async set(s,t){var i;await this.get(s)!=t&&(null===(i=this.sessionStorage)||void 0===i||i.setItem(this.prefix+s,t),this.eventBus.emit(n.DataChanged,{provider:this.name}))}}const h=class{constructor(t){s(this,t),this.name="session"}registerProvider(){a(this.name,this.provider),this.actionSubscription=i.on(this.name,(async s=>{if(s.command==e.SetData){const{data:t}=s;await Promise.all(Object.keys(s.data).map((s=>this.provider.set(s,t[s]))))}}))}componentWillLoad(){this.provider=new c(window,r,this.name,this.keyPrefix),this.registerProvider()}disconnectedCallback(){var s;o(this.name),null===(s=this.actionSubscription)||void 0===s||s.call(this)}render(){return null}get el(){return t(this)}};export{h as n_data_session}