VanJS and a spice of DML, my Holy Graal Quest is finished...

artydev - Jun 4 '23 - - Dev Community

For many years, I have been in a search of a micro frontend UI library which would fill my needs, I can assure you that I have tried many of them...

DML was quite there, but I missed reactivity, so I created MVU which was based on DML an Morphdom.

Finally arrived the little gem VanJS and spiced by DML concepts, my Graal was finally there, a big thank to Tao and Eckehard.

I can finally dedicated my time to create and no to search anymore...

And, let us see for the last time, the famous Counter with VanJS spiced by DML.

Oh, did I said that all is under 2k JS !!!

Demo

import van from "./van.js"

const {div, h1, button } = van.tags;
const {begin, end, state} = van;

const bdiv = () => begin(div());

function Counter (start = 0) {
  const counter = state(start);
  let view = bdiv();
    h1("Counter ", counter)
    button("INC").onclick = () => ++counter.val;
  end()
  return view
}

const style_app = `
  border:1px solid black;
  padding: 10px;
  background:orange`

begin(document.body)
  let app = bdiv ()
    h1({style:"text-align:center"}, "Demo VanJS / DML")
    Counter(0)
    Counter(4)
    Counter(56)
  end()
  h1("Here is an orphan counter")
  Counter(12)
  app.style = style_app;
end()
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .