-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
Thank you for the great library. It has been a great experience so far.
I am trying to wrap bucklescript-tea component into web components. The initial skeleton looks like this:
import { main } from './Demo.bs.js';
// Library function to register a custom element
export function define(name, mainFn) {
const componentClass = class extends HTMLElement {
constructor() {
super();
// Attach a shadow root to the element.
let shadowRoot = this.attachShadow({ mode: 'open' });
mainFn(shadowRoot);
}
};
customElements.define(name, componentClass);
}
// Application code
define('hello-world', main);I was wondering if you have any suggestions for observing props in a typesafe manner. Currently, I am thinking of manually accepting the list of prop string to be observed and adding setter for each prop. Something like this:
define('hello-world', main, ['prop1', 'prop2']);
The plan is to either raise a custom event or call pushMessage directly from the prop setter. I am not sure if this is the right approach. Any suggestions on how I can do interoperability with JavaScript; specifically in the context of custom elements?
Metadata
Metadata
Assignees
Labels
No labels