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

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

Issue 315173005: Add "last" setter to List. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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) 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
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
148 int get length => _internal.length; 155 int get length => _internal.length;
149 156
150 void set length(int value) { 157 void set length(int value) {
151 _internal.length = value; 158 _internal.length = value;
152 recordGlobalChange(); 159 recordGlobalChange();
153 } 160 }
154 161
155 void clear() { 162 void clear() {
156 _internal.clear(); 163 _internal.clear();
157 recordGlobalChange(); 164 recordGlobalChange();
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 // Only fire on an actual change. 361 // Only fire on an actual change.
355 if (!identical(newValue, _value)) { 362 if (!identical(newValue, _value)) {
356 final oldValue = _value; 363 final oldValue = _value;
357 _value = newValue; 364 _value = newValue;
358 recordPropertyUpdate("value", newValue, oldValue); 365 recordPropertyUpdate("value", newValue, oldValue);
359 } 366 }
360 } 367 }
361 368
362 T _value; 369 T _value;
363 } 370 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698