| Index: pkg/observe/lib/src/change_record.dart
|
| diff --git a/pkg/observe/lib/src/change_record.dart b/pkg/observe/lib/src/change_record.dart
|
| index 99e806ddb373b56d528f884d74be91dd7413badc..bb584e8f427aa2e35f0e9dc612a774094e0c21c8 100644
|
| --- a/pkg/observe/lib/src/change_record.dart
|
| +++ b/pkg/observe/lib/src/change_record.dart
|
| @@ -5,22 +5,41 @@
|
| part of observe;
|
|
|
| /** Records a change to an [Observable]. */
|
| -abstract class ChangeRecord {
|
| - // TODO(jmesserly): rename this--it's confusing. Perhaps "matches"?
|
| - /** True if the change affected the given item, otherwise false. */
|
| - bool changes(key);
|
| -}
|
| +// TODO(jmesserly): remove this type
|
| +abstract class ChangeRecord {}
|
|
|
| /** A change record to a field of an observable object. */
|
| -class PropertyChangeRecord extends ChangeRecord {
|
| - /** The field that was changed. */
|
| - final Symbol field;
|
| +class PropertyChangeRecord<T> extends ChangeRecord {
|
| + /**
|
| + * *Deprecated* use [name] instead.
|
| + * The field that was changed.
|
| + */
|
| + @deprecated
|
| + Symbol get field => name;
|
| +
|
| + /** The object that changed. */
|
| + final object;
|
| +
|
| + /** The name of the property that changed. */
|
| + final Symbol name;
|
|
|
| - PropertyChangeRecord(this.field);
|
| + /** The previous value of the property. */
|
| + final T oldValue;
|
|
|
| - bool changes(key) => key is Symbol && field == key;
|
| + /** The new value of the property. */
|
| + final T newValue;
|
|
|
| - String toString() => '#<PropertyChangeRecord $field>';
|
| + PropertyChangeRecord(this.object, this.name, this.oldValue, this.newValue);
|
| +
|
| + /*
|
| + * *Deprecated* instead of `record.changes(key)` simply do
|
| + * `key == record.name`.
|
| + */
|
| + @deprecated
|
| + bool changes(key) => key is Symbol && name == key;
|
| +
|
| + String toString() =>
|
| + '#<PropertyChangeRecord $name from: $oldValue to: $newValue>';
|
| }
|
|
|
| /** A change record for an observable list. */
|
| @@ -41,16 +60,23 @@ class ListChangeRecord extends ChangeRecord {
|
| }
|
| }
|
|
|
| + /**
|
| + * *Deprecated* use [indexChanged] instead.
|
| + * Returns true if the provided index was changed by this operation.
|
| + */
|
| + @deprecated
|
| + bool changes(value) => indexChanged(value);
|
| +
|
| /** Returns true if the provided index was changed by this operation. */
|
| - bool changes(key) {
|
| + bool indexChanged(otherIndex) {
|
| // If key isn't an int, or before the index, then it wasn't changed.
|
| - if (key is! int || key < index) return false;
|
| + if (otherIndex is! int || otherIndex < index) return false;
|
|
|
| // If this was a shift operation, anything after index is changed.
|
| if (addedCount != removedCount) return true;
|
|
|
| // Otherwise, anything in the update range was changed.
|
| - return key < index + addedCount;
|
| + return otherIndex < index + addedCount;
|
| }
|
|
|
| String toString() => '#<ListChangeRecord index: $index, '
|
|
|