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

Unified Diff: pkg/mdv/lib/src/text.dart

Issue 20149004: [mdv] implement Node.createBinding and Node.createBindings (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
Index: pkg/mdv/lib/src/text.dart
diff --git a/pkg/mdv/lib/src/text.dart b/pkg/mdv/lib/src/text.dart
index 6d2b380011938a85dc7227b7feb82f221b42a7fc..f17ba2dc65d29585c4e1de95abe2e0eba0b3625c 100644
--- a/pkg/mdv/lib/src/text.dart
+++ b/pkg/mdv/lib/src/text.dart
@@ -8,37 +8,16 @@ part of mdv;
class _TextExtension extends _NodeExtension {
_TextExtension(Text node) : super(node);
- Text get node => super.node;
-
- StreamSubscription _textBinding;
-
- void bind(String name, model, String path) {
- if (name != 'text') {
- super.bind(name, model, path);
- return;
- }
-
- unbind('text');
-
- _textBinding = new PathObserver(model, path).bindSync((value) {
- node.text = value == null ? '' : '$value';
- });
+ NodeBinding createBinding(String name, model, String path) {
+ if (name == 'text') return new _TextBinding(node, model, path);
+ return super.createBinding(name, model, path);
}
+}
- void unbind(String name) {
- if (name != 'text') {
- super.unbind(name);
- return;
- }
-
- if (_textBinding == null) return;
-
- _textBinding.cancel();
- _textBinding = null;
- }
+class _TextBinding extends NodeBinding {
+ _TextBinding(node, model, path) : super(node, 'text', model, path);
- void unbindAll() {
- unbind('text');
- super.unbindAll();
+ void boundValueChanged(newValue) {
+ node.text = sanitizeBoundValue(newValue);
}
}

Powered by Google App Engine
This is Rietveld 408576698