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

Side by Side Diff: pkg/observe/lib/src/bindable.dart

Issue 355133002: switch Node.bind to interop (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/observe/lib/src/observer_transform.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library observe.src.bindable; 5 library observe.src.bindable;
6 6
7 /// An object that can be data bound. 7 /// An object that can be data bound.
8 // Normally this is used with 'package:template_binding'. 8 // Normally this is used with 'package:template_binding'.
9 // TODO(jmesserly): Node.bind polyfill calls this "observable" 9 // TODO(jmesserly): Node.bind polyfill calls this "observable"
10 abstract class Bindable { 10 abstract class Bindable {
11 // TODO(jmesserly): since we have "value", should open be a void method?
12 // Dart note: changed setValue to be "set value" and discardChanges() to 11 // Dart note: changed setValue to be "set value" and discardChanges() to
13 // be "get value". Also "set value" implies discard changes. 12 // be "get value".
14 // TOOD(jmesserly): is this change too subtle? Is there any other way to
15 // make Bindable friendly in a world with getters/setters?
16 13
17 /// Initiates observation and returns the initial value. 14 /// Initiates observation and returns the initial value.
18 /// The callback will be called with the updated [value]. 15 /// The callback will be called with the updated [value].
19 /// 16 ///
20 /// Some subtypes may chose to provide additional arguments, such as 17 /// Some subtypes may chose to provide additional arguments, such as
21 /// [PathObserver] providing the old value as the second argument. 18 /// [PathObserver] providing the old value as the second argument.
22 /// However, they must support callbacks with as few as 0 or 1 argument. 19 /// However, they must support callbacks with as few as 0 or 1 argument.
23 /// This can be implemented by performing an "is" type test on the callback. 20 /// This can be implemented by performing an "is" type test on the callback.
24 open(callback); 21 open(callback);
25 22
26 /// Stops future notifications and frees the reference to the callback passed 23 /// Stops future notifications and frees the reference to the callback passed
27 /// to [open], so its memory can be collected even if this Bindable is alive. 24 /// to [open], so its memory can be collected even if this Bindable is alive.
28 void close(); 25 void close();
29 26
30 /// Gets the current value of the bindings. 27 /// Gets the current value of the bindings.
28 /// Note: once the value of a [Bindable] is fetched, the callback passed to
29 /// [open] should not be called again with this new value.
30 /// In other words, any pending change notifications must be discarded.
31 // TODO(jmesserly): I don't like a getter with side effects. Should we just
32 // rename the getter/setter pair to discardChanges/setValue like they are in
33 // JavaScript?
31 get value; 34 get value;
32 35
33 /// This can be implemented for two-way bindings. By default does nothing. 36 /// This can be implemented for two-way bindings. By default does nothing.
34 /// Note: setting the value of a [Bindable] must not call the [callback] with
35 /// the new value. Any pending change notifications must be discarded.
36 set value(newValue) {} 37 set value(newValue) {}
38
39 /// Deliver changes. Typically this will perform dirty-checking, if any is
40 /// needed.
41 void deliver() {}
37 } 42 }
OLDNEW
« no previous file with comments | « no previous file | pkg/observe/lib/src/observer_transform.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698