Observable constructor
Observable(})
Implementation
Observable(this.key, dynamic value,
{this.scope,
OnChangeCallback? listener,
this.getter,
this.setter,
this.formatter,
this.lazyEvaluation = false}) {
if (value is String) {
// bindings?
if (this is! BlobObservable) {
bindings = Binding.getBindings(value, scope: scope);
}
if (bindings != null) {
// replace the "this" and "parent" operators
value = replaceReferences(this, scope, value);
// save the signature
signature = value;
}
// eval?
isEval = isEvalSignature(value);
if (_isEval == true) {
value = getEvalSignature(value);
signature = value;
}
// 2-way
String t = '@{';
if ((bindings != null) &&
(bindings!.length == 1) &&
(value.trim().toLowerCase().startsWith(t)) &&
(value.trim().toLowerCase().endsWith('}'))) {
twoway = true;
value = (value as String).substring(1);
signature = value;
}
}
// Set the Value
if (bindings == null) _value = to(value);
// Perform Evaluation
if ((isEval) || bindings != null) onObservableChange(null);
// Add Listener
if (listener != null) registerListener(listener);
// Register
if (scope != null) scope!.register(this);
// Notify
notifyListeners();
}