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

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

Issue 23643008: Move observe to observe package (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | « pkg/observe/lib/src/list_path_observer.dart ('k') | pkg/polymer/lib/observe.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 part of observe; 5 part of observe;
6 6
7 /** 7 /**
8 * Use `@observable` to make a field automatically observable. 8 * Use `@observable` to make a field automatically observable.
9 */ 9 */
10 const Object observable = const _ObservableAnnotation(); 10 const Object observable = const _ObservableAnnotation();
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 * will not schedule [deliverChanges]; use [Observable.dirtyCheck] instead. 185 * will not schedule [deliverChanges]; use [Observable.dirtyCheck] instead.
186 */ 186 */
187 void notifyChange(ChangeRecord record) { 187 void notifyChange(ChangeRecord record) {
188 if (!hasObservers) return; 188 if (!hasObservers) return;
189 189
190 if (_records == null) _records = []; 190 if (_records == null) _records = [];
191 _records.add(record); 191 _records.add(record);
192 } 192 }
193 } 193 }
194 194
195 /**
196 * Notify the property change. Shorthand for:
197 *
198 * target.notifyChange(new PropertyChangeRecord(targetName));
199 */
200 void notifyProperty(Observable target, Symbol targetName) {
201 target.notifyChange(new PropertyChangeRecord(targetName));
202 }
203
195 // TODO(jmesserly): remove the instance method and make this top-level method 204 // TODO(jmesserly): remove the instance method and make this top-level method
196 // public instead? 205 // public instead?
197 _notifyPropertyChange(Observable obj, Symbol field, Object oldValue, 206 _notifyPropertyChange(Observable obj, Symbol field, Object oldValue,
198 Object newValue) { 207 Object newValue) {
199 208
200 // TODO(jmesserly): should this be == instead of identical, to prevent 209 // TODO(jmesserly): should this be == instead of identical, to prevent
201 // spurious loops? 210 // spurious loops?
202 if (obj.hasObservers && !identical(oldValue, newValue)) { 211 if (obj.hasObservers && !identical(oldValue, newValue)) {
203 obj.notifyChange(new PropertyChangeRecord(field)); 212 obj.notifyChange(new PropertyChangeRecord(field));
204 } 213 }
205 return newValue; 214 return newValue;
206 } 215 }
207 216
208 217
209 /** 218 /**
210 * The type of the `@observable` annotation. 219 * The type of the `@observable` annotation.
211 * 220 *
212 * Library private because you should be able to use the [observable] field 221 * Library private because you should be able to use the [observable] field
213 * to get the one and only instance. We could make it public though, if anyone 222 * to get the one and only instance. We could make it public though, if anyone
214 * needs it for some reason. 223 * needs it for some reason.
215 */ 224 */
216 class _ObservableAnnotation { 225 class _ObservableAnnotation {
217 const _ObservableAnnotation(); 226 const _ObservableAnnotation();
218 } 227 }
OLDNEW
« no previous file with comments | « pkg/observe/lib/src/list_path_observer.dart ('k') | pkg/polymer/lib/observe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698