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

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

Issue 132403010: big update to observe, template_binding, polymer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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/observe/lib/observe.dart ('k') | pkg/observe/lib/src/compound_path_observer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/observe/lib/src/bindable.dart
diff --git a/pkg/observe/lib/src/bindable.dart b/pkg/observe/lib/src/bindable.dart
new file mode 100644
index 0000000000000000000000000000000000000000..636ef3034364f352155df1fa35d15fe58402adb7
--- /dev/null
+++ b/pkg/observe/lib/src/bindable.dart
@@ -0,0 +1,35 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library observe.src.bindable;
+
+/// An object that can be data bound.
+// Normally this is used with 'package:template_binding'.
+// TODO(jmesserly): Node.bind polyfill calls this "observable"
+abstract class Bindable {
+ // TODO(jmesserly): since we have "value", should open be a void method?
+ // TODO(jmesserly): not sure how I feel about open taking a variable number
+ // of arguments, but it's the easiest way to make CompoundObserver work.
+
+ /// Initiates observation and returns the initial value.
+ /// The callback will be called with the updated [value].
+ ///
+ /// Some subtypes may chose to provide additional arguments, such as
+ /// [PathObserver] providing the old value as the second argument.
+ /// However, they must support callbacks with as few as 0 or 1 argument.
+ /// This can be implemented by performing an "is" type test on the callback.
+ open(callback);
+
+ /// Stops future notifications and frees the reference to the callback passed
+ /// to [open], so its memory can be collected even if this Bindable is alive.
+ void close();
+
+ /// Gets the current value of the bindings.
+ get value;
+
+ /// This can be implemented for two-way bindings. By default does nothing.
+ /// Note: setting the value of a [Bindable] must not call the [callback] with
+ /// the new value. Any pending change notifications must be discarded.
+ set value(newValue) {}
+}
« no previous file with comments | « pkg/observe/lib/observe.dart ('k') | pkg/observe/lib/src/compound_path_observer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698