Chromium Code Reviews| 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..d9730fc356bf75d88424512f2f52709925f3dd8a 100644 |
| --- a/pkg/observe/lib/src/change_record.dart |
| +++ b/pkg/observe/lib/src/change_record.dart |
| @@ -5,22 +5,38 @@ |
| 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* use == [name] instead. */ |
|
Siggi Cherem (dart-lang)
2013/10/17 02:04:56
use ` ` to quote the code sample? maybe:
*Depreca
Jennifer Messerly
2013/10/17 03:25:12
good idea, done
|
| + @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 +57,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, ' |