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

Unified Diff: pkg/observe/lib/src/observable_map.dart

Issue 20886002: add custom_element package (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/observe/lib/src/observable.dart ('k') | pkg/observe/test/observe_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/observe/lib/src/observable_map.dart
diff --git a/pkg/observe/lib/src/observable_map.dart b/pkg/observe/lib/src/observable_map.dart
index 2cd64d57d1b52749b4cac6a6b5b47e524cea709b..621c86fa5afc413a2a4dea5cb009909153b93bb8 100644
--- a/pkg/observe/lib/src/observable_map.dart
+++ b/pkg/observe/lib/src/observable_map.dart
@@ -67,9 +67,7 @@ class ObservableMap<K, V> extends ChangeNotifierBase implements Map<K, V> {
* you should use [toObservable].
*/
factory ObservableMap.from(Map<K, V> other) {
- var result = new ObservableMap<K, V>._createFromType(other);
- other.forEach((key, value) { result[key] = value; });
- return result;
+ return new ObservableMap<K, V>._createFromType(other)..addAll(other);
}
factory ObservableMap._createFromType(Map<K, V> other) {
@@ -114,6 +112,10 @@ class ObservableMap<K, V> extends ChangeNotifierBase implements Map<K, V> {
}
}
+ void addAll(Map<K, V> other) {
+ other.forEach((K key, V value) { this[key] = value; });
+ }
+
V putIfAbsent(K key, V ifAbsent()) {
int len = _map.length;
V result = _map.putIfAbsent(key, ifAbsent);
« no previous file with comments | « pkg/observe/lib/src/observable.dart ('k') | pkg/observe/test/observe_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698