UNPKG

activator-oce-exporter

Version:

Extract Activator binder and convert it to valid OCE mono pacakge

25 lines (21 loc) 832 B
import { FusionLogger } from './fusion-logger'; import { FusionStore } from './fusion-store'; import { registerComponent } from '../_actions/app'; class ComponentsRegistrar { /** * @param {String} componentName - name of component HTML tag * @param {function<FusionBase>} instance - instance of component class */ static register(componentName, instance) { if (!customElements.get(componentName)) { customElements.define(componentName, instance); FusionStore.store.dispatch(registerComponent(componentName)); } else { FusionLogger.warn(`Component ${componentName} already registered`, 'components-registrar'); } } static emitComponentsRegistration() { document.dispatchEvent(new CustomEvent('ComponentsRegistrar:allComponentsRegistered')); } } export { ComponentsRegistrar };