Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Issue 12225039: Support for observable models, fixes #259 (Closed)

Created:
7 years, 10 months ago by Jennifer Messerly
Modified:
7 years, 10 months ago
CC:
reviews_dartlang.org
Base URL:
https://github.com/dart-lang/web-ui.git@master
Visibility:
Public.

Description

Adds support for Observable objects in web_ui. This includes @observable annotation for automatic transformation by DWC. It also includes ObservableList/Map/Set types. Observables use a batch-notification system where changes are queued up and sent to the handler during the "next microtask". This is similar to ES7 Object.observe proposal. We don't have detailed change records yet but I plan to work on that in a follow up change. Keep that in mind when reviewing ObservableList/Map/Set types because they're in for an overhaul. The CL for that isn't ready but for comparison purposes you can find it here: https://chromiumcodereview.appspot.com/12096106/ All tests have been converted. Since I had to go through every single test, I took the liberty of removing incorrect <title> attributes throughout. I still need to convert the MDV and explainer examples. I'm also interested in more perf tests. I'll work on that now, but would prefer not expanding the scope of this (already big) change :) Feature request: https://github.com/dart-lang/web-ui/issues/259 Committed: https://github.com/dart-lang/web-ui/commit/749924d

Patch Set 1 #

Patch Set 2 : remove obsolete todo #

Patch Set 3 : fixes for api-app #

Patch Set 4 : tests passing #

Patch Set 5 : remove old test code #

Patch Set 6 : remove old todo and import #

Patch Set 7 : small formatting fixes #

Total comments: 71

Patch Set 8 : feedback round 1 #

Patch Set 9 : #

Total comments: 65

Patch Set 10 : Round 2, Fight! #

Total comments: 4

Patch Set 11 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+3041 lines, -1089 lines) Patch
M example/todomvc/editable_label.html View 1 2 3 4 5 6 7 8 1 chunk +3 lines, -1 line 0 comments Download
M example/todomvc/main.dart View 1 2 3 1 chunk +1 line, -13 lines 0 comments Download
M example/todomvc/model.dart View 1 2 3 4 5 6 7 8 9 2 chunks +11 lines, -4 lines 0 comments Download
M example/todomvc/router_options.html View 1 2 2 chunks +2 lines, -3 lines 0 comments Download
A lib/observe.dart View 1 2 3 4 5 6 7 8 9 10 1 chunk +494 lines, -0 lines 0 comments Download
A lib/observe/html.dart View 1 2 3 4 5 6 7 8 9 1 chunk +48 lines, -0 lines 0 comments Download
A lib/observe/list.dart View 1 2 3 4 5 6 7 1 chunk +235 lines, -0 lines 0 comments Download
A lib/observe/map.dart View 1 2 3 4 5 6 7 1 chunk +221 lines, -0 lines 0 comments Download
A lib/observe/reference.dart View 1 2 1 chunk +32 lines, -0 lines 0 comments Download
A lib/observe/set.dart View 1 2 3 4 5 6 7 1 chunk +181 lines, -0 lines 0 comments Download
M lib/src/analyzer.dart View 1 2 3 4 5 6 7 8 9 3 chunks +4 lines, -5 lines 0 comments Download
M lib/src/codegen.dart View 1 2 3 3 chunks +9 lines, -34 lines 0 comments Download
M lib/src/compiler.dart View 1 2 3 4 5 6 7 8 9 7 chunks +233 lines, -51 lines 0 comments Download
A lib/src/dart_parser.dart View 1 2 3 1 chunk +174 lines, -0 lines 0 comments Download
D lib/src/directive_parser.dart View 1 2 3 1 chunk +0 lines, -388 lines 0 comments Download
M lib/src/emitters.dart View 1 2 3 4 5 6 7 7 chunks +62 lines, -38 lines 0 comments Download
M lib/src/files.dart View 1 chunk +2 lines, -2 lines 0 comments Download
M lib/src/info.dart View 1 2 3 4 5 6 7 8 9 7 chunks +34 lines, -44 lines 0 comments Download
A lib/src/observable_transform.dart View 1 2 3 4 5 6 7 8 9 1 chunk +211 lines, -0 lines 0 comments Download
A lib/src/refactor.dart View 1 2 3 4 5 6 7 8 9 1 chunk +105 lines, -0 lines 0 comments Download
M lib/templating.dart View 1 2 3 4 5 6 7 8 9 12 chunks +41 lines, -14 lines 0 comments Download
M lib/watcher.dart View 1 2 3 4 5 6 6 chunks +24 lines, -26 lines 0 comments Download
M lib/web_ui.dart View 2 chunks +8 lines, -5 lines 0 comments Download
M pubspec.yaml View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M test/data/expected/element_ctor_test.html.txt View 1 2 3 4 5 6 7 8 9 2 chunks +6 lines, -3 lines 0 comments Download
M test/data/input/attr_multiple_bindings_test.html View 1 2 3 2 chunks +5 lines, -9 lines 0 comments Download
M test/data/input/bind_hyphenated_attribute_test.html View 1 2 3 1 chunk +2 lines, -3 lines 0 comments Download
M test/data/input/code_in_dart_file_component.dart View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M test/data/input/code_in_dart_file_test.html View 1 2 3 2 chunks +1 line, -2 lines 0 comments Download
M test/data/input/common.dart View 1 2 3 4 5 6 7 8 9 2 chunks +3 lines, -1 line 0 comments Download
M test/data/input/component_field_2way_test.html View 1 2 3 4 5 6 7 8 9 3 chunks +12 lines, -4 lines 0 comments Download
M test/data/input/component_field_test.html View 1 2 3 4 5 6 7 8 9 10 1 chunk +10 lines, -3 lines 0 comments Download
M test/data/input/component_imports_component2_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/component_imports_component3_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/component_imports_component_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/component_in_main_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/component_inherit_noscript_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/component_inherit_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/conditional2_test.html View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -3 lines 0 comments Download
M test/data/input/conditional3_test.html View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -4 lines 0 comments Download
M test/data/input/conditional4_test.html View 1 2 3 4 5 6 7 8 9 2 chunks +2 lines, -5 lines 0 comments Download
M test/data/input/conditional5_test.html View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -4 lines 0 comments Download
M test/data/input/conditional_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/constant_argument_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/css_classes_binding_test.html View 1 2 3 4 5 6 7 8 9 4 chunks +4 lines, -4 lines 0 comments Download
M test/data/input/custom_radio_button_test.html View 1 2 3 4 chunks +6 lines, -7 lines 0 comments Download
M test/data/input/dir3/bootstrap_path_test_main.dart View 1 2 3 1 chunk +1 line, -3 lines 0 comments Download
M test/data/input/dom_accessor_binding2_test.html View 1 2 3 4 5 6 7 8 9 1 chunk +4 lines, -5 lines 0 comments Download
M test/data/input/dom_accessor_binding_test.html View 1 2 3 4 5 6 7 8 9 2 chunks +4 lines, -5 lines 0 comments Download
M test/data/input/duplicate_event_listeners_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/element_ctor_test.html View 1 2 3 4 5 6 7 8 9 2 chunks +4 lines, -7 lines 0 comments Download
M test/data/input/empty2_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/empty_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/ensure_parent_test.html View 1 2 3 1 chunk +2 lines, -2 lines 0 comments Download
M test/data/input/escape2_test.html View 1 2 3 4 5 6 7 8 9 1 chunk +6 lines, -7 lines 0 comments Download
M test/data/input/escape_test.html View 1 2 3 1 chunk +4 lines, -4 lines 0 comments Download
M test/data/input/escape_uri_test.html View 1 2 3 2 chunks +2 lines, -1 line 0 comments Download
M test/data/input/html_escape_test.html View 1 2 3 2 chunks +2 lines, -6 lines 0 comments Download
M test/data/input/if_attribute_test.html View 1 2 3 4 5 6 7 8 9 2 chunks +3 lines, -4 lines 0 comments Download
M test/data/input/if_children_test.html View 1 2 3 2 chunks +1 line, -2 lines 0 comments Download
M test/data/input/if_fragments2_test.html View 1 2 3 4 5 6 7 8 9 1 chunk +4 lines, -5 lines 0 comments Download
M test/data/input/if_fragments3_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/if_fragments4_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/if_fragments_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/iterate_attribute_test.html View 1 2 3 4 5 6 7 8 9 1 chunk +3 lines, -4 lines 0 comments Download
M test/data/input/iterate_fragments_test.html View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M test/data/input/list2_test.html View 1 2 3 4 5 6 7 8 9 2 chunks +3 lines, -5 lines 0 comments Download
M test/data/input/list3_test.html View 1 2 3 4 5 6 7 8 9 2 chunks +3 lines, -5 lines 0 comments Download
M test/data/input/list4_test.html View 1 2 3 4 5 6 7 8 9 2 chunks +3 lines, -5 lines 0 comments Download
M test/data/input/list5_test.html View 1 2 3 4 5 6 7 8 9 2 chunks +3 lines, -5 lines 0 comments Download
M test/data/input/list6_test.html View 1 2 3 4 5 6 7 8 9 2 chunks +3 lines, -5 lines 0 comments Download
M test/data/input/list_children_test.html View 1 2 3 2 chunks +1 line, -2 lines 0 comments Download
M test/data/input/list_component_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/list_test.html View 1 2 3 2 chunks +1 line, -2 lines 0 comments Download
M test/data/input/main_code_in_dart_file.dart View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -3 lines 0 comments Download
M test/data/input/mix_iterate_if_test.html View 1 2 3 4 5 6 7 8 9 2 chunks +9 lines, -4 lines 0 comments Download
M test/data/input/news_index_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/path_normalization_test.html View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -3 lines 0 comments Download
M test/data/input/query_in_main_test.html View 1 2 3 1 chunk +2 lines, -1 line 0 comments Download
M test/data/input/radio_button_test.html View 1 2 3 4 chunks +6 lines, -7 lines 0 comments Download
M test/data/input/recursive_component_test.html View 1 2 3 4 5 6 7 8 9 2 chunks +3 lines, -7 lines 0 comments Download
M test/data/input/recursive_test_data.dart View 1 2 3 1 chunk +2 lines, -1 line 0 comments Download
M test/data/input/root_query_no_shadowroot_test.html View 1 2 3 2 chunks +1 line, -2 lines 0 comments Download
M test/data/input/style_binding_test.html View 1 2 3 2 chunks +14 lines, -4 lines 0 comments Download
M test/data/input/table_test.html View 1 2 3 4 5 6 7 8 9 2 chunks +17 lines, -13 lines 0 comments Download
M test/data/input/template_multiple_children_test.html View 1 2 3 2 chunks +1 line, -2 lines 0 comments Download
M test/data/input/template_zero_children_test.html View 1 2 3 2 chunks +1 line, -2 lines 0 comments Download
M test/data/input/text_multiple_bindings_test.html View 1 2 3 4 5 6 7 8 9 2 chunks +2 lines, -6 lines 0 comments Download
M test/data/input/text_top_level2_test.html View 1 2 3 1 chunk +3 lines, -3 lines 0 comments Download
M test/data/input/text_top_level_test.html View 1 2 3 1 chunk +3 lines, -3 lines 0 comments Download
M test/data/input/text_tostring_test.html View 1 2 3 4 5 6 7 8 9 3 chunks +9 lines, -6 lines 0 comments Download
M test/data/input/todomvc_listorder_shadowdom_test.html View 1 2 3 2 chunks +16 lines, -14 lines 0 comments Download
M test/data/input/todomvc_listorder_test.html View 1 2 3 1 chunk +17 lines, -14 lines 0 comments Download
M test/data/input/todomvc_mainpage2_test.html View 1 2 3 1 chunk +2 lines, -2 lines 0 comments Download
M test/data/input/todomvc_mainpage_test.html View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/data/input/todomvc_markdone_test.html View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M test/data/input/watch_global_var2_test.html View 1 2 3 4 5 6 7 8 9 1 chunk +3 lines, -5 lines 0 comments Download
M test/data/input/watch_global_var3_test.html View 1 2 3 1 chunk +2 lines, -3 lines 0 comments Download
M test/data/input/watch_global_var_test.html View 1 2 3 4 5 6 7 8 9 1 chunk +2 lines, -4 lines 0 comments Download
D test/directive_parser_test.dart View 1 2 3 1 chunk +0 lines, -170 lines 0 comments Download
M test/emitter_test.dart View 1 2 3 4 5 6 7 8 9 5 chunks +5 lines, -4 lines 0 comments Download
A test/observe_test.dart View 1 2 3 4 5 6 7 8 9 1 chunk +611 lines, -0 lines 0 comments Download
A + test/perf/input/change_1_of_100_test.html View 2 chunks +19 lines, -19 lines 0 comments Download
A test/perf/input/observe_model.dart View 1 2 3 4 5 1 chunk +13 lines, -0 lines 0 comments Download
M test/run_all.dart View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
Jennifer Messerly
7 years, 10 months ago (2013-02-12 22:49:09 UTC) #1
Siggi Cherem (dart-lang)
This is looking awesome John! I'm still working through it, but I have to interrupt ...
7 years, 10 months ago (2013-02-13 01:43:24 UTC) #2
Jennifer Messerly
Thanks Siggi! Addressed comments so far -- PTAL https://chromiumcodereview.appspot.com/12225039/diff/12001/example/todomvc/editable_label.html File example/todomvc/editable_label.html (right): https://chromiumcodereview.appspot.com/12225039/diff/12001/example/todomvc/editable_label.html#newcode48 example/todomvc/editable_label.html:48: deliverChangesSync(); ...
7 years, 10 months ago (2013-02-13 05:43:15 UTC) #3
Siggi Cherem (dart-lang)
... and here is the second round! This is super cool! https://chromiumcodereview.appspot.com/12225039/diff/12001/lib/observe.dart File lib/observe.dart (right): ...
7 years, 10 months ago (2013-02-13 19:28:54 UTC) #4
Jennifer Messerly
Thanks for review! Some great finds in there, especially for the tests. I'm working through ...
7 years, 10 months ago (2013-02-13 20:21:20 UTC) #5
Siggi Cherem (dart-lang)
https://chromiumcodereview.appspot.com/12225039/diff/12001/lib/observe/map.dart File lib/observe/map.dart (right): https://chromiumcodereview.appspot.com/12225039/diff/12001/lib/observe/map.dart#newcode111 lib/observe/map.dart:111: _notifyWriteLength(len); On 2013/02/13 20:21:20, John Messerly wrote: > On ...
7 years, 10 months ago (2013-02-13 20:41:13 UTC) #6
Jennifer Messerly
PTAL. Think I got everything *fingers crossed* https://chromiumcodereview.appspot.com/12225039/diff/5034/lib/observe.dart File lib/observe.dart (right): https://chromiumcodereview.appspot.com/12225039/diff/5034/lib/observe.dart#newcode287 lib/observe.dart:287: if (i ...
7 years, 10 months ago (2013-02-14 00:38:09 UTC) #7
Siggi Cherem (dart-lang)
lgtm!! (modulo fixing toObservable =)) https://chromiumcodereview.appspot.com/12225039/diff/5034/test/data/input/style_binding_test.html File test/data/input/style_binding_test.html (right): https://chromiumcodereview.appspot.com/12225039/diff/5034/test/data/input/style_binding_test.html#newcode36 test/data/input/style_binding_test.html:36: expect(error, new isInstanceOf<DataBindingError>()); On ...
7 years, 10 months ago (2013-02-14 00:59:25 UTC) #8
Jennifer Messerly
7 years, 10 months ago (2013-02-14 01:48:39 UTC) #9
https://chromiumcodereview.appspot.com/12225039/diff/29002/lib/observe.dart
File lib/observe.dart (right):

https://chromiumcodereview.appspot.com/12225039/diff/29002/lib/observe.dart#n...
lib/observe.dart:146: createMap: () => new LinkedHashMap());
On 2013/02/14 00:59:25, Siggi Cherem (dart-lang) wrote:
> does this fit in the prev line?

Done.

https://chromiumcodereview.appspot.com/12225039/diff/29002/lib/observe.dart#n...
lib/observe.dart:148: return toObservable(value);
On 2013/02/14 00:59:25, Siggi Cherem (dart-lang) wrote:
> infinite loop? 
> find/replace was too eager? =)

haha. Good catch. That's what I get for not rerunning tests right at the end
after the replace. :)

also refactored the createMap code slightly

Powered by Google App Engine
This is Rietveld 408576698