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

Side by Side Diff: sdk/lib/observe/observable_box.dart

Issue 14732003: Implement Model-Driven-Views spec for Dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: small fix Created 7 years, 7 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of dart.observe;
6
7 /**
8 * An observable box that holds a value. Use this if you want to store a single
9 * value. For other cases, it is better to use [ObservableList],
10 * [ObservableMap], or a custom [Observable] implementation based on
11 * [ObservableMixin].
Lasse Reichstein Nielsen 2013/05/06 10:58:58 Document that the key will be the string "value".
Jennifer Messerly 2013/05/07 05:43:38 Done. Also moving this type to package:observe, an
12 */
13 class ObservableBox<T> extends ObservableMixin {
14 T _value;
15
16 ObservableBox([T initialValue]) : _value = initialValue;
17
18 T get value => _value;
19
20 void set value(T newValue) {
21 if (hasObservers) {
22 notifyChange('value', _value, newValue);
23 }
24 _value = newValue;
25 }
26
27 String toString() => '#<$runtimeType value: $value>';
28
29 getValue(key) {
30 if (key == 'value') return value;
31 return null;
32 }
33 void setValue(key, newValue) {
34 if (key == 'value') value = newValue;
35 }
36 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698