js-virtual-dom 0.9.2

Released 2017-09-22.

To install, run:

haxelib install js-virtual-dom 0.9.2

See using Haxelib in Haxelib documentation for more information.

Current version0.9.2
StatisticsInstalled 347 times
Tags js, reactive, virtual-dom



Wrapper for MattEsch's virtual-dom with a bit of Haxe awesomeness sprinkled around the edges.

Adding VDom to the DOM

You can use create, diff and patch from vdom.VDom yourself, if you wish, or you can use a VRoot like so:

import vdom.VDom.*;
import js.Browser.*;

class Main {
  static function main() {
    var root = new vdom.VRoot();


      div({ className: 'test' }, ['hello world'])

      div({ className: 'test' }, ['holla mundo'])

    //And with tink_hxx
      <div class="test">Hi HXX!!!</div>

When compiling with -lib tink_hxx the argument can either be a string constant or a VNode. If you call update with a string constant without -lib tink_hxx you will get a compiler warning, if it looks vaguely like HXX (i.e. the first non-whitespace character is "{" or "<").

While a VRoot can be used as an Element it is not quite the same. For example if you were to call root.update(span({ })) then the <div> will be transparently replaced with a <span>. You can poll the current element with root.currentElement() but keep in mind that it might change over the life time of a VRoot.