sethladd/dart-polymer-dart-examples — pull request #41 by didrocks (2013-12-05 10:20:38+00:00)
Title: Multiples small fixes in examples

Here is a simple and small contribution for the tests repository to refresh it with dart polymer 0.9.1+1 as I went through all examples. You can cherry-pick some of the commits (I tried to have one commit per example) so that you can isolate if you don't like some of the changes.

2 things to note I didn't change:

In gtw_contacts/edit_contact_view.dart:
I'm not sure why we need those 2 lines:
static const EventStreamProvider _EDITDONE_EVENT = const EventStreamProvider("editdone");
Stream get onEditDone => _EDITDONE_EVENT.forTarget(this);

Using element.dispatchEvent(new CustomEvent("editdone", detail: canceled)); seems to be enough to dispatch the event to Polymer? I didn't notice any regression if I tried to remove them.

----

In call_method_on_custom_element:
Maybe some more informations are needed as comments in index.dart about:
scheduleMicrotask(Observable.dirtyCheck);

I think I would have expect (maybe like many others?) that the @observable on the counter integer would have set a notifyPropertyChange() on it and so counter++ in the increment() function wouldn't need nothing else to trigger the UI refresh.
Reading from https://api.dartlang.org/docs/channels/stable/latest/observe.html and http://stackoverflow.com/questions/20186198/implement-an-observer-pattern-in-dart, it seems that's not the case. What do you think of refering that (and maybe having an example with notifyPropertyChange)? Maybe as well, the polymer.dart team sees that as a bug that will be fixed (only once Object.observe is activated in the browser?)?

I seems in other examples that it's a scoping issue: if the increment() is called in a timer from within the Element class, the counter change is seen, otherwise, it's not:
in my_element.dart
@override
enteredView() {
super.enteredView();
_timer = new Timer.periodic(const Duration(seconds: 1), (_) {
increment();
});
}
-> works without dirtychecking.

Anyway, I think a comment to explain it would be necessary :)