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

Side by Side Diff: pkg/observe/lib/src/change_notifier.dart

Issue 53743002: introduce ObservableList.listChanges to keep list changes separate from property changes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
« no previous file with comments | « pkg/observe/lib/observe.dart ('k') | pkg/observe/lib/src/change_record.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 library observe.src.change_notifier; 5 library observe.src.change_notifier;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection' show UnmodifiableListView; 8 import 'dart:collection' show UnmodifiableListView;
9 import 'package:observe/observe.dart'; 9 import 'package:observe/observe.dart';
10 import 'package:observe/src/observable.dart' show notifyPropertyChangeHelper; 10 import 'package:observe/src/observable.dart' show notifyPropertyChangeHelper;
(...skipping 22 matching lines...) Expand all
33 // for subclasses. Ideally they'd be protected. 33 // for subclasses. Ideally they'd be protected.
34 /** 34 /**
35 * Override this method to be called when the [changes] are first observed. 35 * Override this method to be called when the [changes] are first observed.
36 */ 36 */
37 void observed() {} 37 void observed() {}
38 38
39 /** 39 /**
40 * Override this method to be called when the [changes] are no longer being 40 * Override this method to be called when the [changes] are no longer being
41 * observed. 41 * observed.
42 */ 42 */
43 void unobserved() {} 43 void unobserved() {
44 // Free some memory
45 _changes = null;
46 }
44 47
45 bool deliverChanges() { 48 bool deliverChanges() {
46 var records = _records; 49 var records = _records;
47 _records = null; 50 _records = null;
48 if (hasObservers && records != null) { 51 if (hasObservers && records != null) {
49 _changes.add(new UnmodifiableListView<ChangeRecord>(records)); 52 _changes.add(new UnmodifiableListView<ChangeRecord>(records));
50 return true; 53 return true;
51 } 54 }
52 return false; 55 return false;
53 } 56 }
(...skipping 25 matching lines...) Expand all
79 void notifyChange(ChangeRecord record) { 82 void notifyChange(ChangeRecord record) {
80 if (!hasObservers) return; 83 if (!hasObservers) return;
81 84
82 if (_records == null) { 85 if (_records == null) {
83 _records = []; 86 _records = [];
84 scheduleMicrotask(deliverChanges); 87 scheduleMicrotask(deliverChanges);
85 } 88 }
86 _records.add(record); 89 _records.add(record);
87 } 90 }
88 } 91 }
OLDNEW
« no previous file with comments | « pkg/observe/lib/observe.dart ('k') | pkg/observe/lib/src/change_record.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698