Riot.hx — haxe wrapper for Riot

francesco agati
2 min readJun 7, 2015

--

Riot is a javascript library for user interface similar to facebook React virtual-dom but more light weight and with a simple interface.

I have just create a Haxe wrapper around this library powered by the haxe macros.

Create a Riot component is really simple.

  • Add using Riot.RiotTools
  • You must only create a class that implements riot.IRiotComponent interface.
  • Create a public instance var called view
  • in the new method call the bind_view method (see the gist at the bottom)
  • and add a series of annotation that describe the component
    @tagName specifiy the tag name of the component
    @templateFile define the path of the riot template
    @cssFile define the css path file that is injected inside the page
    @autoMount is used to mount the compoment on page load event
  • you can bind the class method to the riot events use the annotation @:bind

Inline annotations

you can use also inline template instead of use files.
Use annotations @:template and @:css

Components inheritance
Riot.hx use the class inheritance for share code between components.

If you create a class that implements riot.IRiotComponent without class annoation; you can use this class as base class for children class compoments.

you can find the lib on haxelib

and github

--

--

francesco agati

crazy for Ruby, Haxe, smalltalk(pharo),Javascript and Lisp/scheme(racket). Love metaprogramming. Yoga Martials Arts Medtitation Shiatsu.