Bob Nystrom made a great statement regarding dart:html on the G+
hangout yesterday (btw, thanks Seth, Bob, and team - it was great). I
paraphrase: "dart:html should be at least as easy to work with as
dart:dom, if not easier'.
Understanding that getting measurement properties from the DOM causes
layout overhead, it makes sense that in many, I'll say "atomic"
situations, you can do this asynchronously. You can even do a bunch
of measurements asynchronously and then wait in requestLayoutFrame().
However, in more complex situations where you have layered flow
control, all needing measurements, and where you may also have other
asynchronous callbacks performing measurements, using the async model
becomes, in my opinion untenable. Can this scenario be solved? Yes,
but there is a great deal more heavy lifting involved just to get at
these metrics, and this is where I think it goes counter to the spirit
of what dart:html is all about.
I don't have an example of this anymore because I ripped it all out
and moved back to dart:dom in my project a while ago. I've got async
in Grid.dart and FrameworkElement.dart back at this commit
08581883cf9f2874ae2fe0731a0140f34c50935d if you really want to dig in
(git://
github.com/LUCA-Studios-LLC/LUCA-UI-Framework-for-Dart.git).
That scenario may turn out to be just a corner case, but I suspect as
more and more larger-scale client-side apps are written, it will come
up more often. I suggest that the Dart team get ahead of it, by
simply exposing the synchronous measurements - giving developers the
choice of which way to go based on application requirements.
I'm aware that there may be performance issues with the CSS3
transforms when doing sync layouts, but I think this too is manageable
(vs async), especially in a large-scale apps where all of that is
tightly managed anyway.
I would also speculate that async measuring may prove a barrier to
entry for the javascript community at-large, when they've been used to
sync measuring for so long.