Permalink
Browse files

feature: ObservableProperty got a name field - helps to debug

  • Loading branch information...
MikeMitterer committed Jul 31, 2015
1 parent f852199 commit cb4aa533f00880a1464990337373692d2c5787c4
Showing with 10 additions and 1 deletion.
  1. +1 −0 lib/src/core/MdlComponentHandler.dart
  2. +9 −1 lib/src/observable/ObservableProperty.dart
@@ -514,6 +514,7 @@ class MdlComponentHandler {
if(component != null) {
component.attributes.remove(_DATA_KEY);
component.classes.add(_cssClasses.DOWNGRADED);
component = null;
}
} on String catch (e) {
@@ -28,16 +28,22 @@ class PropertyChangeEvent<T> {
@MdlComponentModel
class ObservableProperty<T> {
static const String _DEFAULT_NAME = "<undefinded>";
final Logger _logger = new Logger('mdlobservable.ObservableProperty');
T _value;
Function _observe;
Duration _interval = new Duration(milliseconds: 100);
bool _pause = false;
/// Observername - helps with debugging!
final String _name;
StreamController<PropertyChangeEvent<T>> _onChange;
ObservableProperty(this._value,{ T observe(), final Duration interval } ) {
ObservableProperty(this._value,{ T observe(), final Duration interval,
final String name: ObservableProperty._DEFAULT_NAME } ) : _name = name {
if(interval != null) {
_interval = interval;
@@ -132,6 +138,8 @@ class ObservableProperty<T> {
}
void _fire(final PropertyChangeEvent<T> event) {
if(_name != ObservableProperty._DEFAULT_NAME) { _logger.info("Fireing $event from ${_name}..."); }
if(_onChange != null && _onChange.hasListener) {
_onChange.add(event);
}

0 comments on commit cb4aa53

Please sign in to comment.