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

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

Issue 26967004: add @MirrorsUsed to observe/polymer/polymer_exprs pkgs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix typo in comment Created 7 years, 2 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
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 part of observe; 5 part of observe;
6 6
7 /** 7 /**
8 * Use `@observable` to make a field automatically observable.
9 */
10 const ObservableProperty observable = const ObservableProperty();
11
12 /**
13 * Interface representing an observable object. This is used by data in 8 * Interface representing an observable object. This is used by data in
14 * model-view architectures to notify interested parties of [changes]. 9 * model-view architectures to notify interested parties of [changes].
15 * 10 *
16 * This object does not require any specific technique to implement 11 * This object does not require any specific technique to implement
17 * observability. If you mixin [ObservableMixin], [dirtyCheck] will know to 12 * observability. If you mixin [ObservableMixin], [dirtyCheck] will know to
18 * check for changes on the object. You may also implement change notification 13 * check for changes on the object. You may also implement change notification
19 * yourself, by calling [notifyChange]. 14 * yourself, by calling [notifyChange].
20 * 15 *
21 * You can use [ObservableBase] or [ObservableMixin] to implement this. 16 * You can use [ObservableBase] or [ObservableMixin] to implement this.
22 */ 17 */
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 _notifyPropertyChange(Observable obj, Symbol field, Object oldValue, 205 _notifyPropertyChange(Observable obj, Symbol field, Object oldValue,
211 Object newValue) { 206 Object newValue) {
212 207
213 // TODO(jmesserly): should this be == instead of identical, to prevent 208 // TODO(jmesserly): should this be == instead of identical, to prevent
214 // spurious loops? 209 // spurious loops?
215 if (obj.hasObservers && !identical(oldValue, newValue)) { 210 if (obj.hasObservers && !identical(oldValue, newValue)) {
216 obj.notifyChange(new PropertyChangeRecord(field)); 211 obj.notifyChange(new PropertyChangeRecord(field));
217 } 212 }
218 return newValue; 213 return newValue;
219 } 214 }
220
221
222 /**
223 * An annotation that is used to make a property observable.
224 * Normally this is used via the [observable] constant, for example:
225 *
226 * class Monster {
227 * @observable int health;
228 * }
229 *
230 * If needed, you can subclass this to create another annotation that will also
231 * be treated as observable.
232 */
233 class ObservableProperty {
234 const ObservableProperty();
235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698