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

Unified Diff: pkg/observe/lib/src/compound_binding.dart

Issue 19771010: implement dirty checking for @observable objects (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: logging for loops in dirty checking Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/observe/lib/src/compound_binding.dart
diff --git a/pkg/observe/lib/src/compound_binding.dart b/pkg/observe/lib/src/compound_binding.dart
index c239abeea0bbe95ebaa1554e1596364da30554d8..15e3e03007ef8078c29f9d4388aece5098d18d25 100644
--- a/pkg/observe/lib/src/compound_binding.dart
+++ b/pkg/observe/lib/src/compound_binding.dart
@@ -8,8 +8,13 @@ part of observe;
typedef Object CompoundBindingCombinator(Map objects);
/**
- * Model-Driven Views contains a helper object which is useful for the
- * implementation of a Custom Syntax.
+ * CompoundBinding is an object which knows how to listen to multiple path
+ * values (registered via [bind]) and invoke its [combinator] when one or more
+ * of the values have changed and set its [value] property to the return value
+ * of the function. When any value has changed, all current values are provided
+ * to the [combinator] in the single `values` argument.
+ *
+ * For example:
*
* var binding = new CompoundBinding((values) {
* var combinedValue;
@@ -20,15 +25,9 @@ typedef Object CompoundBindingCombinator(Map objects);
* binding.bind('name2', obj2, path2);
* //...
* binding.bind('nameN', objN, pathN);
- *
- * CompoundBinding is an object which knows how to listen to multiple path
- * values (registered via [bind]) and invoke its [combinator] when one or more
- * of the values have changed and set its [value] property to the return value
- * of the function. When any value has changed, all current values are provided
- * to the [combinator] in the single `values` argument.
*/
// TODO(jmesserly): rename to something that indicates it's a computed value?
-class CompoundBinding extends ObservableBase {
+class CompoundBinding extends ChangeNotifierBase {
CompoundBindingCombinator _combinator;
// TODO(jmesserly): ideally these would be String keys, but sometimes we
@@ -65,6 +64,8 @@ class CompoundBinding extends ObservableBase {
void bind(name, model, String path) {
unbind(name);
+ // TODO(jmesserly): should we avoid observing until we are observed,
+ // similar to PathObserver? Similar for unobserving?
_bindings[name] = new PathObserver(model, path).bindSync((value) {
_values[name] = value;
_scheduleResolve();
@@ -86,7 +87,7 @@ class CompoundBinding extends ObservableBase {
void _scheduleResolve() {
if (_scheduled) return;
_scheduled = true;
- queueChangeRecords(resolve);
+ runAsync(resolve);
}
void resolve() {

Powered by Google App Engine
This is Rietveld 408576698