yjbanov / butterfly

A web framework for Dart based on Flutter's widget model
Apache License 2.0
157 stars 13 forks source link

Back to dart:html #34

Closed yjbanov closed 6 years ago

yjbanov commented 6 years ago

This PR ditches package:js in favor or dart:html

jonahwilliams commented 6 years ago

Found an issue while using this locally:

If there is no event associated with a setState call, then renderFrame never gets called. potential modification is to remove the root event listener in the Tree and instead call this after setState somehow.

Ideally multiple calls to setState won't call renderFrame multiple times. Something like this:

bool _isRendering = false;
void scheduleUpdate() {
  if (!_isRendering) {
    _isRendering = true;
    scheduleMicrotask(() {
     tree.renderFrame();
     _isRendering = false;
   });
  }
}
yjbanov commented 6 years ago

Good catch. Should it be a microtask or requestAnimationFrame?

jonahwilliams commented 6 years ago

requestAnimationFrame makes more sense to me since we can more easily batch an update across the entire app

yjbanov commented 6 years ago

Yes! Travis works again!