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.

29 lines (28 loc) 598 B
/*! * NENT 2022 */ /* istanbul ignore file */ import { EventEmitter } from '../../common/emitter'; import { DATA_EVENTS } from '../interfaces'; export class DataItemProvider { constructor(data, setter) { this.data = data; this.setter = setter; this.changed = new EventEmitter(); } async get(key) { if (key === 'item') { return this.data; } return this.data[key]; } async set(key, value) { if (this.setter) { await this.setter(key, value); } else { this.data[key] = value; } this.changed.emit(DATA_EVENTS.DataChanged); } }