onObservableChange method
dynamic
onObservableChange(
- Observable? observable
)
Implementation
onObservableChange(Observable? observable)
{
String? template = signature;
// resolve all bindings
Map<String?, dynamic>? variables;
if ((bindings != null) && (scope != null))
for (Binding binding in bindings!)
{
dynamic v;
// get binding source
Observable? source = scope!.getObservable(binding, requestor: observable);
if (source != null)
{
dynamic _value = source.get();
v = binding.translate(_value);
}
// is this an eval?
if (isEval)
{
if (variables == null) variables = Map<String?, dynamic>();
if ((source is BLOB.BlobObservable) && (!S.isNullOrEmpty(v)))
variables[binding.signature] = 'blob';
else variables[binding.signature] = v;
}
// simple replacement of string values
else
{
v = S.toStr(v) ?? "";
template = template!.replaceAll(binding.signature, v.toString());
}
}
// set the value
dynamic value = (isEval) ? doEvaluation(signature, variables: variables) : template;
// 2-way binding?
if (observable?.twoway == this) value = observable!.value;
// set the target value
set(value);
}