| OLD | NEW |
| 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 // TODO(jmesserly): this needs to be faster. We currently require multiple | 7 // TODO(jmesserly): this needs to be faster. We currently require multiple |
| 8 // lookups per key to get the old value. | 8 // lookups per key to get the old value. |
| 9 // TODO(jmesserly): this doesn't implement the precise interfaces like | 9 // TODO(jmesserly): this doesn't implement the precise interfaces like |
| 10 // LinkedHashMap, SplayTreeMap or HashMap. However it can use them for the | 10 // LinkedHashMap, SplayTreeMap or HashMap. However it can use them for the |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 MapChangeRecord(this.key, this.oldValue, this.newValue) | 33 MapChangeRecord(this.key, this.oldValue, this.newValue) |
| 34 : isInsert = false, isRemove = false; | 34 : isInsert = false, isRemove = false; |
| 35 | 35 |
| 36 MapChangeRecord.insert(this.key, this.newValue) | 36 MapChangeRecord.insert(this.key, this.newValue) |
| 37 : isInsert = true, isRemove = false; | 37 : isInsert = true, isRemove = false; |
| 38 | 38 |
| 39 MapChangeRecord.remove(this.key, this.oldValue) | 39 MapChangeRecord.remove(this.key, this.oldValue) |
| 40 : isInsert = false, isRemove = true; | 40 : isInsert = false, isRemove = true; |
| 41 | 41 |
| 42 /// *Deprecated* compare [key]s instead. |
| 43 @deprecated |
| 44 bool changes(otherKey) => key == otherKey; |
| 45 |
| 42 String toString() { | 46 String toString() { |
| 43 var kind = isInsert ? 'insert' : isRemove ? 'remove' : 'set'; | 47 var kind = isInsert ? 'insert' : isRemove ? 'remove' : 'set'; |
| 44 return '#<MapChangeRecord $kind $key from: $oldValue to: $newValue>'; | 48 return '#<MapChangeRecord $kind $key from: $oldValue to: $newValue>'; |
| 45 } | 49 } |
| 46 } | 50 } |
| 47 | 51 |
| 48 /** | 52 /** |
| 49 * Represents an observable map of model values. If any items are added, | 53 * Represents an observable map of model values. If any items are added, |
| 50 * removed, or replaced, then observers that are listening to [changes] | 54 * removed, or replaced, then observers that are listening to [changes] |
| 51 * will be notified. | 55 * will be notified. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 }); | 153 }); |
| 150 notifyPropertyChange(#length, len, 0); | 154 notifyPropertyChange(#length, len, 0); |
| 151 } | 155 } |
| 152 _map.clear(); | 156 _map.clear(); |
| 153 } | 157 } |
| 154 | 158 |
| 155 void forEach(void f(K key, V value)) => _map.forEach(f); | 159 void forEach(void f(K key, V value)) => _map.forEach(f); |
| 156 | 160 |
| 157 String toString() => Maps.mapToString(this); | 161 String toString() => Maps.mapToString(this); |
| 158 } | 162 } |
| OLD | NEW |