Bug fix on Observable.notifyChange (#18)
* Bug fix on Observable.notifyChange
* Better fix.
* Actual better fix.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b41cd9a..a1cc51d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/lib/src/observable.dart b/lib/src/observable.dart
index 2d2c49e..0990b96 100644
--- a/lib/src/observable.dart
+++ b/lib/src/observable.dart
@@ -22,7 +22,7 @@
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.
///
@@ -80,19 +80,15 @@
/*=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;
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 57ce0ad..7519461 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: observable
-version: 0.18.0
+version: 0.18.1
author: Dart Team <misc@dartlang.org>
description: Support for marking objects as observable
homepage: https://github.com/dart-lang/observable