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

Side by Side Diff: samples/swarm/swarm_ui_lib/observable/observable.dart

Issue 11361190: a === b -> identical(a, b) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 1 month 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 library observable; 5 library observable;
6 6
7 import 'dart:coreimpl'; 7 import 'dart:coreimpl';
8 8
9 part 'ChangeEvent.dart'; 9 part 'ChangeEvent.dart';
10 part 'EventBatch.dart'; 10 part 'EventBatch.dart';
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 recordListRemove(index, found); 208 recordListRemove(index, found);
209 } 209 }
210 return found; 210 return found;
211 } 211 }
212 212
213 int indexOf(T element, [int start = 0]) { 213 int indexOf(T element, [int start = 0]) {
214 return _internal.indexOf(element, start); 214 return _internal.indexOf(element, start);
215 } 215 }
216 216
217 int lastIndexOf(T element, [int start = null]) { 217 int lastIndexOf(T element, [int start = null]) {
218 if (start === null) start = length - 1; 218 if (start == null) start = length - 1;
219 return _internal.lastIndexOf(element, start); 219 return _internal.lastIndexOf(element, start);
220 } 220 }
221 221
222 bool removeFirstElement(T element) { 222 bool removeFirstElement(T element) {
223 // the removeAt above will record the event. 223 // the removeAt above will record the event.
224 return (removeAt(indexOf(element, 0)) != null); 224 return (removeAt(indexOf(element, 0)) != null);
225 } 225 }
226 226
227 int removeAllElements(T element) { 227 int removeAllElements(T element) {
228 int count = 0; 228 int count = 0;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // "new ObservableValue<DataType>(myValue)". 278 // "new ObservableValue<DataType>(myValue)".
279 /** A wrapper around a single value whose change can be observed. */ 279 /** A wrapper around a single value whose change can be observed. */
280 class ObservableValue<T> extends AbstractObservable { 280 class ObservableValue<T> extends AbstractObservable {
281 ObservableValue(T value, [Observable parent = null]) 281 ObservableValue(T value, [Observable parent = null])
282 : super(parent), _value = value; 282 : super(parent), _value = value;
283 283
284 T get value => _value; 284 T get value => _value;
285 285
286 void set value(T newValue) { 286 void set value(T newValue) {
287 // Only fire on an actual change. 287 // Only fire on an actual change.
288 // TODO(terry): An object identity test === is needed. Each DataSource has 288 if (!identical(newValue, _value)) {
289 // its own operator == which does a value compare. Which
290 // equality check should be done?
291 if (newValue !== _value) {
292 final oldValue = _value; 289 final oldValue = _value;
293 _value = newValue; 290 _value = newValue;
294 recordPropertyUpdate("value", newValue, oldValue); 291 recordPropertyUpdate("value", newValue, oldValue);
295 } 292 }
296 } 293 }
297 294
298 T _value; 295 T _value;
299 } 296 }
OLDNEW
« no previous file with comments | « samples/swarm/swarm_ui_lib/base/Size.dart ('k') | samples/swarm/swarm_ui_lib/touch/ClickBuster.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698