Lit element or Using class components

If I have to write bindings for this, how should we go about it

 import {html, css, LitElement} from 'lit';

export class SimpleGreeting extends LitElement {
  static styles = css`p { color: blue }`;

  static properties = {
    name: {type: String},
  };

  constructor() {
    super();
    this.name = 'Somebody';
  }

  render() {
    return html`<p>Hello, ${this.name}!</p>`;
  }
}
customElements.define('simple-greeting', SimpleGreeting);

To be clear, its not about consuming the component, but to write one.

1 Like

I’d wrap the class in a function factory and have written bindings for the function.

1 Like

You can’t express those semantics in ReScript unfortunately.

1 Like

Does rescript have better tools to express this now after v11.1?

we now have tagged template functions in rescript v11.1.

But we still have no semantics around classes and I don’t think we have any plans for that. The best solution likely to follow DZakh’s advice, create a function factory in JS and write bindings to it.

2 Likes