I want to find a really clean way to integrate frappe with polymer. I want a class that is
- a true frappe Property / EventStream
- directly usable in as a property in polymer expressions
So far I've sketched out the following
class ObservableProperty<T> extends PropertyProxy<T> with ChangeNotifier {
StreamSubscription _subscription;
T _oldValue;
final Symbol _propertyName;
ObservableProperty(Property<T> property, this._propertyName) : super(property);
@override
void observed() {
if (_subscription == null) {
_subscription = listen((T v) {
final old = _oldValue;
_oldValue = v;
notifyPropertyChange(_propertyName, old, v);
});
}
}
@override
void unobserved() {
if (_subscription != null) {
_subscription.cancel();
}
}
}
Unfortunately PropertyProxy is like
class PropertyProxy<T> implements Property<T> {
final Property _property;
PropertyProxy(this._property);
@override
Property operator *(Property other) => _property * other;
... 74 other methods like this :-(
That is because there is no easy way to extend Property or mix it in. Firstly all the constructors are factories (which I think is just a left over from previous versions of Frappe) but also the methods directly invoke property constructors like
so will not return any derived class. Totally understandable but a pain when trying to extend.
Please add some support for making this easier.
Of course I wouldn't be upset if you directly supported the observe package so I didn't need to build the extension ;-)
I want to find a really clean way to integrate frappe with polymer. I want a class that is
So far I've sketched out the following
Unfortunately PropertyProxy is like
That is because there is no easy way to extend Property or mix it in. Firstly all the constructors are factories (which I think is just a left over from previous versions of Frappe) but also the methods directly invoke property constructors like
so will not return any derived class. Totally understandable but a pain when trying to extend.
Please add some support for making this easier.
Of course I wouldn't be upset if you directly supported the observe package so I didn't need to build the extension ;-)