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

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

Issue 21451002: Speed up CompoundBindings (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « pkg/mdv/lib/src/template_iterator.dart ('k') | pkg/observe/test/list_change_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 625c82c535a8d6645e88dc50431e2a27e75b9958..925cff58f60e636fffecac4822c484d58be68b1f 100644
--- a/pkg/observe/lib/src/compound_binding.dart
+++ b/pkg/observe/lib/src/compound_binding.dart
@@ -34,9 +34,22 @@ class CompoundBinding extends ChangeNotifierBase {
// use integers.
Map<dynamic, StreamSubscription> _observers = new Map();
Map _values = new Map();
- bool _scheduled = false;
Object _value;
+ /**
+ * True if [resolve] is scheduled. You can set this to true if you plan to
+ * call [resolve] manually, avoiding the need for scheduling an asynchronous
+ * resolve.
+ */
+ // TODO(jmesserly): I don't like having this public, is the optimization
+ // really needed? "runAsync" in Dart should be pretty cheap.
+ bool scheduled;
+
+ /**
+ * Creates a new CompoundBinding, optionally proving the [combinator] function
+ * for computing the value. You can also set [schedule] to true if you plan
+ * to invoke [resolve] manually after initial construction of the binding.
+ */
CompoundBinding([CompoundBindingCombinator combinator]) {
// TODO(jmesserly): this is a tweak to the original code, it seemed to me
// that passing the combinator to the constructor should be equivalent to
@@ -86,14 +99,14 @@ class CompoundBinding extends ChangeNotifierBase {
// TODO(rafaelw): Consider having a seperate ChangeSummary for
// CompoundBindings so to excess dirtyChecks.
void _scheduleResolve() {
- if (_scheduled) return;
- _scheduled = true;
+ if (scheduled) return;
+ scheduled = true;
runAsync(resolve);
}
void resolve() {
if (_observers.isEmpty) return;
- _scheduled = false;
+ scheduled = false;
if (_combinator == null) {
throw new StateError(
« no previous file with comments | « pkg/mdv/lib/src/template_iterator.dart ('k') | pkg/observe/test/list_change_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698