@modls/core

0.6.5 • Public • Published

Node.js Package

Modls (pronounched as Modules)

How To Use Modls

Install the module via npm i @modls/core and consume it as such:

import { Component, html } from "@modls/core";

Alternatively you can use a CDN such as unpkg:

import { html, Component } from "https://unpkg.com/@modls/core";

Example

import { html, Component, registerComponent } from "@modls/core";

export default class ExampleClass extends Component {
  static get props() {
    return { startFrom: 0 };
  }
  onMount() {
    console.log("Mount");
    this.setState({ number: this.props.startFrom });
  }
  onDidUpdate(oldProps, oldState) {
    console.log(oldProps, oldState);
  }
  onDidMount() {
    console.log("Mounted");
  }
  onWillUnmount() {
    console.log("Unmount");
  }
  updateNumber() {
    if (this.state.number === 10) {
      this.remove();
    } else {
      this.setState({ number: this.state.number + 1 });
    }
  }
  render() {
    return html`
      Started from ${this.props.startFrom} <br />
      <button onclick=${() => this.updateNumber()}>
        Clicked ${this.state.number} times
      </button>
    `;
  }
}

registerComponent(ExampleClass);

Thanks to

Rendering methods of lighterhtml

Package Sidebar

Install

npm i @modls/core

Weekly Downloads

1

Version

0.6.5

License

ISC

Unpacked Size

61.4 kB

Total Files

19

Last publish

Collaborators

  • dominicvonk