Flow : a reactive template POC

205 views
Skip to first unread message

Justin Donaldson

unread,
Jul 6, 2014, 9:57:01 PM7/6/14
to Haxe
https://github.com/jdonaldson/flow

I'm working on a macro driven reactive template based system.  It uses an xml template to specify arbitrary graphics classes (flash.display.DisplayObject-based ones for now), and uses the node attributes to set up some simple bindings using promhx.Stream.

The source itself is a simple demo that you can try out.  It's using OpenFl, and works in flash and neko (most likely others, haven't tested much).

The idea is to provide a simple model via an anonymous object, and a template scheme given as an xml string:


Flow.on({x:100, y:1}, " <flash.text.TextField text='hello world' :x='x' .y='4'/> ");
Flow binds the model to the template, creating the display objects referenced in the tags, and links the fields to the given attribute values.  You can check the readme for more details on binding.

I'm still not handling all the cases for parent/child relationships in the xml tags, but that should come soon.

Best,
-Justin

Juraj Kirchheim

unread,
Jul 7, 2014, 3:29:30 AM7/7/14
to haxe...@googlegroups.com
Did you check out Hxmr? (https://github.com/HxJointForces/Hxmr)

It might be interesting to have a more lightweight alternative though.

Best,
Juraj

Justin Donaldson

unread,
Jul 7, 2014, 10:00:45 AM7/7/14
to Haxe

I had it flagged.  Hxmr looked promising, but it's incomplete and has been stagnant for a year or so.  I couldn't get the examples to compile.  Thanks for the reminder to check again though, it has a nice xml parser library that gives position information.

Rather than re-implement mxml,  I thought it would be nice to steal some ideas from other libraries.  I liked React's notion of a virtual dom.  I think something similar would work well for displaylist as well.  I'd also like to try an alternative constraint-based layout mechanism.  Finally, having something that worked well with update/add/remove mappings would be nice for visualizations.  Franco has a dhx library that I'm familiar with that works on the dom like d3.

It all starts with the model binding though, and I wanted to have something fast and flexible there.  Right now, the plan was to provide an initial "bootstrap" model that contains the starting values, bind them to template parameters, and allow them to be updated individually by Streams.  The next steps would include sorting out parent-child relationships among the nodes, and implementing simple iteration (mapping arrays of elements, etc.).  Then I wanted to try to allow replacing the entire model at once, and update the template efficiently.  This would do the delta transformations on the display list a la React.  I'm not sure if I can resolve that with the current Stream based approach, but we'll see.

Best,
-Justin

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Cambiata

unread,
Jul 8, 2014, 4:20:47 AM7/8/14
to haxe...@googlegroups.com
  I liked React's notion of a virtual dom.  I think something similar would work well for displaylist as well. 

+1!

Dima Granetchi

unread,
Jul 8, 2014, 5:12:01 AM7/8/14
to haxe...@googlegroups.com
Hi!

I am developer of Hxmr library. Hxmr library is under construction, but now I work on another realisation. This is small example https://gist.github.com/profelis/04d6be81f96548ad8dfc 
Current library support flash display list, StablexUI library, openfl and simple targets like flash or neko and some external features.

If you are interested contact me

Justin Donaldson

unread,
Jul 9, 2014, 12:01:23 AM7/9/14
to Haxe
Of course I'm interested!  Can we see the library?


Dima Granetchi

unread,
Jul 9, 2014, 5:50:01 AM7/9/14
to haxe...@googlegroups.com
You can see some working samples here https://bitbucket.org/profelis/hml/src/a94691e2204de4ee53047e40e618fe375eecfec3/samples/?at=master

Issues and pull requests are welcome
Reply all
Reply to author
Forward
0 new messages