Skip to content

Commit

Permalink
Bug fix on Observable.notifyChange (#18)
Browse files Browse the repository at this point in the history
* Bug fix on Observable.notifyChange

* Better fix.

* Actual better fix.
  • Loading branch information
matanlurey authored Nov 22, 2016
1 parent ca00061 commit c9b6340
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.18.1

* Bug fix: Do not throw when `Observable<T>.notifyChange` is used

## 0.18.0

* Refactor and deprecate `ObservableList`-specific API
Expand Down
24 changes: 10 additions & 14 deletions lib/src/observable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class Observable<C extends ChangeRecord> {
final ChangeNotifier<C> _delegate = new ChangeNotifier<C>();

// Whether Observable was not given a type.
final bool _isNotGeneric = C == dynamic;
final bool _supportsPropertyChanges = PropertyChangeRecord is C;

/// Emits a list of changes when the state of the object changes.
///
Expand Down Expand Up @@ -80,19 +80,15 @@ abstract class Observable<C extends ChangeRecord> {
/*=T*/
newValue,
) {
if (hasObservers && oldValue != newValue) {
if (_isNotGeneric) {
notifyChange(
new PropertyChangeRecord(
this,
field,
oldValue,
newValue,
) as C,
);
} else {
throw new UnsupportedError('Generic typed Observable does not support');
}
if (hasObservers && oldValue != newValue && _supportsPropertyChanges) {
notifyChange(
new PropertyChangeRecord(
this,
field,
oldValue,
newValue,
) as C,
);
}
return newValue;
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: observable
version: 0.18.0
version: 0.18.1
author: Dart Team <[email protected]>
description: Support for marking objects as observable
homepage: https://github.com/dart-lang/observable
Expand Down

0 comments on commit c9b6340

Please sign in to comment.