import Store from '../modules/store.js'; import text from '../modules/text.js'; class AppBase extends HTMLElement { constructor() { super(); this.attachShadow({ mode: 'open' }); this.text = text; this.store = new Store(); } connectedCallback() { this.store.subscribe(this.render.bind(this)); this.render(); } renderText() { const textList = this.store.getRecords(); return textList.map((item) => ``).join('\n'); } render(action = 'INITIAL') { if (![Store.actions.ADD_LINE, Store.actions.REMOVE_LINE, Store.actions.UNDO, 'INITIAL'].includes(action)) { return; // Only render if content changed } this.shadowRoot.innerHTML = ` Delete Add Undo `; } } customElements.define('app-base', AppBase);