Skip to content
Snippets Groups Projects
kb-reactivity.js 1.13 KiB
Newer Older
import { store, Sib, StoreMixin } from 'https://cdn.skypack.dev/@startinblox/core@0.14';
// import { store } from '/scripts/sib-core/dist/index.js';

export const KbReactivity = {
  name: 'kb-reactivity',
  use: [StoreMixin],
  attributes: {
    targetSrc: {
      type: String,
      default: '',
      callback: function () {
        this.subscribe();
      }
    },
    dataSrc: {
      type: String,
      default: '',
      callback: async function (value) {
        // this.resourceId = null;
        // if (this.nestedField) {
        //   const resource = store.get(value) || await store.getData(value, this.context);
        //   const nestedResource = await resource[this.nestedField]
        //   this.resourceId = nestedResource ? nestedResource['@id'] : null;
        // } else {
        //   this.resourceId = value;
        // }
        // this.subscribe();
      }
    },
  },
  subscribe() {
    // if (this.resourceId && this.targetSrc) {
    //   store.subscribeVirtualContainerTo(this.resourceId, this.targetSrc);
    //   store.subscribeVirtualContainerTo(this.targetSrc, this.resourceId);
    // }
  }
}

Sib.register(KbReactivity);