I've been playing around with Dart for a day,
been doing a huge Flex project for 2 years, but the next one will have to be
HTML,
so I decided to give it a good look, as I always do, by developing a small
project.
I chose to try and build a very small Flex-like framework and see how far I
could get.
Doing so, I really started liking this Dart, and the mini Flex stuff is doing
what it is supposed to do.
Some things that I decided to create :
- framework events
// Dart has DOM events, but nothing outside of DOM objects
- list collection
// Like ArrayCollection, it takes an Iterator as source, and dispatches events
on add, remove, ... to facilitate a dataProvider functionality in a component
- layouts
// vertical and horizontal layouts to position elements within a DIV
- group, hgroup, vgroup
// They represent a container, in my case a DIV, and have a layout to position
elements that are added to it
- combo box
// wraps around a HTML select
UI components, like their Flex counterparts, would have a life cycle,
and functionality to invalidate a component after properties are set, or the
layout needs updating.
Dart has operator overloads, so my invalidateProperties for example looks like
this :
set foo(Bar value) {
_foo = value;
// on the next update cycle, trigger commitProperties and handle the new
property value
later > commitProperties;
}
The ListCollection has similar overloads, so you can do :
ListCollection list = new List();
// add 2 elements to the list
list + foo;
list + bar;
// invert the list
list = -list;
ComboBox box = new ComboBox();
box + foo; // adds foo to the internal dataProvider of box
As in Flex, assign a ListCollection to a ComboBox, and any direct changes to
the list will update the ComboBox as well.
Bring them all together and you get something like :
void main() {
// assign a DIV to a VGroup
// VGroup auto has vertical layout
VGroup container = new VGroup('#html_div_id');
ComboBox comboBox = new ComboBox();
ComboBox anotherComboBox = new ComboBox();
container.add(comboBox);
container.add(anotherComboBox);
comboBox + {label: 'item 1'};
comboBox + {label: 'item 2'};
anotherComboBox + {label: 'item 3'};
anotherComboBox + {label: 'item 4'};
}
I'm only a good day in Dart, but liking it a lot.
Dunno if someone is already doing a dart flex project, could very well be, I
just wanted to get my hands dirty for now,
would a dart flex framework be something worth considering for the Apache Flex
project?
I am well aware of the FalconJS effords, but they could be evaluated in
parallel?