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

Unified Diff: third_party/pkg/angular/lib/change_detection/change_detection.dart

Issue 256553002: Revert "Update all Angular libs (run update_all.sh)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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
Index: third_party/pkg/angular/lib/change_detection/change_detection.dart
diff --git a/third_party/pkg/angular/lib/change_detection/change_detection.dart b/third_party/pkg/angular/lib/change_detection/change_detection.dart
index 71f1b97dce02165fa9003e022f2597231389ef1b..5db6300cdf864d5773920e7640df7fbceadaa443 100644
--- a/third_party/pkg/angular/lib/change_detection/change_detection.dart
+++ b/third_party/pkg/angular/lib/change_detection/change_detection.dart
@@ -1,6 +1,6 @@
library change_detection;
-typedef void EvalExceptionHandler(error, stack);
+typedef EvalExceptionHandler(error, stack);
/**
* An interface for [ChangeDetectorGroup] groups related watches together. It
@@ -13,48 +13,49 @@ abstract class ChangeDetectorGroup<H> {
* Watch a specific [field] on an [object].
*
* If the [field] is:
- * * _name_ - Name of the property to watch. (If the [object] is a Map then
+ * - _name_ - Name of the property to watch. (If the [object] is a Map then
* treat the name as a key.)
- * * _null_ - Watch all the items for arrays and maps otherwise the object
- * identity.
+ * - _[]_ - Watch all items in an array.
+ * - _{}_ - Watch all items in a Map.
+ * - _._ - Watch the actual object identity.
+ *
*
* Parameters:
- * * [object] to watch.
- * * [field] to watch on the [object].
- * * [handler] an opaque object passed on to [Record].
+ * - [object] to watch.
+ * - [field] to watch on the [object].
+ * - [handler] an opaque object passed on to [ChangeRecord].
*/
WatchRecord<H> watch(Object object, String field, H handler);
- /// Remove all the watches in an efficient manner.
+ /** Use to remove all watches in the group in an efficient manner. */
void remove();
- /// Create a child [ChangeDetectorGroup]
+ /** Create a child [ChangeDetectorGroup] */
ChangeDetectorGroup<H> newGroup();
}
/**
* An interface for [ChangeDetector]. An application can have multiple instances
- * of the [ChangeDetector] to be used for checking different application
- * domains.
+ * of the [ChangeDetector] to be used for checking different application domains.
*
* [ChangeDetector] works by comparing the identity of the objects not by
* calling the `.equals()` method. This is because ChangeDetector needs to have
* predictable performance, and the developer can implement `.equals()` on top
* of identity checks.
*
- * [H] A [Record] has associated handler object. The handler object is opaque
- * to the [ChangeDetector] but it is meaningful to the code which registered the
- * watcher. It can be a data structure, an object, or a function. It is up to
- * the developer to attach meaning to it.
+ * - [H] A [ChangeRecord] has associated handler object. The handler object is
+ * opaque to the [ChangeDetector] but it is meaningful to the code which
+ * registered the watcher. It can be a data structure, an object, or a function.
+ * It is up to the developer to attach meaning to it.
*/
abstract class ChangeDetector<H> extends ChangeDetectorGroup<H> {
/**
* This method does the work of collecting the changes and returns them as a
- * linked list of [Record]s. The [Record]s are returned in the
+ * linked list of [ChangeRecord]s. The [ChangeRecord]s are returned in the
* same order as they were registered.
*/
- Iterator<Record<H>> collectChanges({EvalExceptionHandler exceptionHandler,
- AvgStopwatch stopwatch });
+ ChangeRecord<H> collectChanges({ EvalExceptionHandler exceptionHandler,
+ AvgStopwatch stopwatch });
}
abstract class Record<H> {
@@ -63,9 +64,10 @@ abstract class Record<H> {
/**
* The field which is being watched:
- * * _name_ - Name of the field to watch.
- * * _null_ - Watch all the items for arrays and maps otherwise the object
- * identity.
+ * - _name_ - Name of the field to watch.
+ * - _[]_ - Watch all items in an array.
+ * - _{}_ - Watch all items in a Map.
+ * - _._ - Watch the actual object identity.
*/
String get field;
@@ -76,16 +78,9 @@ abstract class Record<H> {
*/
H get handler;
- /**
- * * The current value of the [field] on the [object],
- * * a [CollectionChangeRecord] if an iterable is observed,
- * * a [MapChangeRecord] if a map is observed.
- */
+ /** Current value of the [field] on the [object] */
get currentValue;
- /**
- * * Previous value of the [field] on the [object],
- * * [:null:] when an iterable or a map are observed.
- */
+ /** Previous value of the [field] on the [object] */
get previousValue;
}
@@ -94,31 +89,51 @@ abstract class Record<H> {
* manually triggering the checking.
*/
abstract class WatchRecord<H> extends Record<H> {
- /// Set a new object for checking
+ /** Set a new object for checking */
set object(value);
- /// Returns [:true:] when changes have been detected
- bool check();
+ /**
+ * Check to see if the field on the object has changed. Returns [null] if no
+ * change, or a [ChangeRecord] if a change has been detected.
+ */
+ ChangeRecord<H> check();
void remove();
}
/**
+ * Provides information about the changes which were detected in objects.
+ *
+ * It exposes a `nextChange` method for traversing all of the changes.
+ */
+abstract class ChangeRecord<H> extends Record<H> {
+ /** Next [ChangeRecord] */
+ ChangeRecord<H> get nextChange;
+}
+
+/**
* If the [ChangeDetector] is watching a [Map] then the [currentValue] of
- * [Record] will contain an instance of [MapChangeRecord]. A [MapChangeRecord]
+ * [Record] will contain an instance of this object. A [MapChangeRecord]
* contains the changes to the map since the last execution. The changes are
* reported as a list of [MapKeyValue]s which contain the key as well as its
* current and previous value.
*/
abstract class MapChangeRecord<K, V> {
- /// The underlying map object
+ /// The underlying iterable object
Map get map;
- void forEachItem(void f(MapKeyValue<K, V> item));
- void forEachPreviousItem(void f(MapKeyValue<K, V> previousItem));
- void forEachChange(void f(MapKeyValue<K, V> change));
- void forEachAddition(void f(MapKeyValue<K, V> addition));
- void forEachRemoval(void f(MapKeyValue<K, V> removal));
+ /// A list of [CollectionKeyValue]s which are in the iteration order. */
+ KeyValue<K, V> get mapHead;
+ /// A list of changed items.
+ ChangedKeyValue<K, V> get changesHead;
+ /// A list of new added items.
+ AddedKeyValue<K, V> get additionsHead;
+ /// A list of removed items
+ RemovedKeyValue<K, V> get removalsHead;
+
+ void forEachChange(void f(ChangedKeyValue<K, V> change));
+ void forEachAddition(void f(AddedKeyValue<K, V> addition));
+ void forEachRemoval(void f(RemovedKeyValue<K, V> removal));
}
/**
@@ -136,23 +151,46 @@ abstract class MapKeyValue<K, V> {
V get currentValue;
}
+abstract class KeyValue<K, V> extends MapKeyValue<K, V> {
+ KeyValue<K, V> get nextKeyValue;
+}
+
+abstract class AddedKeyValue<K, V> extends MapKeyValue<K, V> {
+ AddedKeyValue<K, V> get nextAddedKeyValue;
+}
+
+abstract class RemovedKeyValue<K, V> extends MapKeyValue<K, V> {
+ RemovedKeyValue<K, V> get nextRemovedKeyValue;
+}
+
+abstract class ChangedKeyValue<K, V> extends MapKeyValue<K, V> {
+ ChangedKeyValue<K, V> get nextChangedKeyValue;
+}
+
+
/**
* If the [ChangeDetector] is watching an [Iterable] then the [currentValue] of
- * [Record] will contain an instance of [CollectionChangeRecord]. The
- * [CollectionChangeRecord] contains the changes to the collection since the
- * last execution. The changes are reported as a list of [CollectionChangeItem]s
- * which contain the item as well as its current and previous index.
+ * [Record] will contain this object. The [CollectionChangeRecord] contains the
+ * changes to the collection since the last execution. The changes are reported
+ * as a list of [CollectionChangeItem]s which contain the item as well as its
+ * current and previous position in the list.
*/
abstract class CollectionChangeRecord<V> {
/** The underlying iterable object */
Iterable get iterable;
- int get length;
- void forEachItem(void f(CollectionChangeItem<V> item));
- void forEachPreviousItem(void f(CollectionChangeItem<V> previousItem));
- void forEachAddition(void f(CollectionChangeItem<V> addition));
- void forEachMove(void f(CollectionChangeItem<V> move));
- void forEachRemoval(void f(CollectionChangeItem<V> removal));
+ /** A list of [CollectionItem]s which are in the iteration order. */
+ CollectionItem<V> get collectionHead;
+ /** A list of new [AddedItem]s. */
+ AddedItem<V> get additionsHead;
+ /** A list of [MovedItem]s. */
+ MovedItem<V> get movesHead;
+ /** A list of [RemovedItem]s. */
+ RemovedItem<V> get removalsHead;
+
+ void forEachAddition(void f(AddedItem<V> addition));
+ void forEachMove(void f(MovedItem<V> move));
+ void forEachRemoval(void f(RemovedItem<V> removal));
}
/**
@@ -160,24 +198,46 @@ abstract class CollectionChangeRecord<V> {
* which tracks the [item]s [currentKey] and [previousKey] location.
*/
abstract class CollectionChangeItem<V> {
- /** Previous item location in the list or [:null:] if addition. */
+ /** Previous item location in the list or [null] if addition. */
int get previousIndex;
- /** Current item location in the list or [:null:] if removal. */
+ /** Current item location in the list or [null] if removal. */
int get currentIndex;
/** The item. */
V get item;
}
-typedef dynamic FieldGetter(object);
-typedef void FieldSetter(object, value);
+/**
+ * Used to create a linked list of collection items. These items are always in
+ * the iteration order of the collection.
+ */
+abstract class CollectionItem<V> extends CollectionChangeItem<V> {
+ CollectionItem<V> get nextCollectionItem;
+}
+
+/**
+ * A linked list of new items added to the collection. These items are always in
+ * the iteration order of the collection.
+ */
+abstract class AddedItem<V> extends CollectionChangeItem<V> {
+ AddedItem<V> get nextAddedItem;
+}
-abstract class FieldGetterFactory {
- get isMethodInvoke;
- bool isMethod(Object object, String name);
- Function method(Object object, String name);
- FieldGetter getter(Object object, String name);
+/**
+ * A linked list of items moved in the collection. These items are always in
+ * the iteration order of the collection.
+ */
+abstract class MovedItem<V> extends CollectionChangeItem<V> {
+ MovedItem<V> get nextMovedItem;
+}
+
+/**
+ * A linked list of items removed from the collection. These items are always
+ * in the iteration order of the collection.
+ */
+abstract class RemovedItem<V> extends CollectionChangeItem<V> {
+ RemovedItem<V> get nextRemovedItem;
}
class AvgStopwatch extends Stopwatch {

Powered by Google App Engine
This is Rietveld 408576698