| OLD | NEW |
| 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 part 'ChangeEvent.dart'; | 7 part 'ChangeEvent.dart'; |
| 8 part 'EventBatch.dart'; | 8 part 'EventBatch.dart'; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 ObservableList([Observable parent = null]) | 138 ObservableList([Observable parent = null]) |
| 139 : super(parent), _internal = new List<T>(); | 139 : super(parent), _internal = new List<T>(); |
| 140 | 140 |
| 141 T operator [](int index) => _internal[index]; | 141 T operator [](int index) => _internal[index]; |
| 142 | 142 |
| 143 void operator []=(int index, T value) { | 143 void operator []=(int index, T value) { |
| 144 recordListUpdate(index, value, _internal[index]); | 144 recordListUpdate(index, value, _internal[index]); |
| 145 _internal[index] = value; | 145 _internal[index] = value; |
| 146 } | 146 } |
| 147 | 147 |
| 148 void set last(T value) { | |
| 149 if (length == 0) throw new StateError("No element"); | |
| 150 int index = length - 1; | |
| 151 recordListUpdate(index, value, _internal[index]); | |
| 152 _internal[index] = value; | |
| 153 } | |
| 154 | |
| 155 int get length => _internal.length; | 148 int get length => _internal.length; |
| 156 | 149 |
| 157 void set length(int value) { | 150 void set length(int value) { |
| 158 _internal.length = value; | 151 _internal.length = value; |
| 159 recordGlobalChange(); | 152 recordGlobalChange(); |
| 160 } | 153 } |
| 161 | 154 |
| 162 void clear() { | 155 void clear() { |
| 163 _internal.clear(); | 156 _internal.clear(); |
| 164 recordGlobalChange(); | 157 recordGlobalChange(); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 // Only fire on an actual change. | 354 // Only fire on an actual change. |
| 362 if (!identical(newValue, _value)) { | 355 if (!identical(newValue, _value)) { |
| 363 final oldValue = _value; | 356 final oldValue = _value; |
| 364 _value = newValue; | 357 _value = newValue; |
| 365 recordPropertyUpdate("value", newValue, oldValue); | 358 recordPropertyUpdate("value", newValue, oldValue); |
| 366 } | 359 } |
| 367 } | 360 } |
| 368 | 361 |
| 369 T _value; | 362 T _value; |
| 370 } | 363 } |
| OLD | NEW |