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

Side by Side Diff: lib/observe/reference.dart

Issue 12096106: work in progress: observable implementation using detailed change records (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: Created 7 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 unified diff | Download patch
« no previous file with comments | « lib/observe/observable.dart ('k') | lib/observe/set.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, 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 library web_ui.observe.reference;
6
7 import 'package:web_ui/observe.dart';
8
9 /**
10 * An observable reference to an value. Use this if you want to store a single
11 * value. NOTE: it is generally better to use the `@observable` annotation on
12 * your observable class. This class is provided for demonstration purposes, or
13 * if you happen to need a single unnamed observable reference.
14 */
15 class ObservableReference<T> extends Observable {
16 T _value;
17
18 ObservableReference([T initialValue]) : _value = initialValue;
19
20 T get value {
21 if (observeReads) notifyRead(ChangeRecord.FIELD, 'value');
22 return _value;
23 }
24
25 void set value(T newValue) {
26 if (hasObservers) {
27 notifyChange(ChangeRecord.FIELD, 'value', _value, newValue);
28 }
29 _value = newValue;
30 }
31 }
OLDNEW
« no previous file with comments | « lib/observe/observable.dart ('k') | lib/observe/set.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698