DEV Community

loading...

Swiss and Mithril

artydev
・1 min read

Continuing my experimentation with Swiss, here is an integration with my favorite library

HTML part

<s-test count="0"></s-test>
<s-test count="10"></s-test>
<s-test count="40"></s-test>
<s-test count="180"></s-test>

JS part

/* Look Ma, no hooks :-) */
let Counter = function (el) {
  let count = parseInt(el.getAttribute("count"));
  return  {
    view: () => [
      m("h1", `Counter : ${count}`),
      m("button", {onclick: () => count++}, "Inc")
  ]}
}

swiss.element("s-test", Counter, swiss.renderer(m.mount));  

You can play with it Here Swiss&Mithril

Discussion (0)