|
|
@ -99,37 +99,42 @@ namespace Avalonia |
|
|
|
|
|
|
|
|
void IObserver<object>.OnNext(object value) |
|
|
void IObserver<object>.OnNext(object value) |
|
|
{ |
|
|
{ |
|
|
void Signal() |
|
|
void Signal(PriorityBindingEntry instance, object newValue) |
|
|
{ |
|
|
{ |
|
|
var notification = value as BindingNotification; |
|
|
var notification = newValue as BindingNotification; |
|
|
|
|
|
|
|
|
if (notification != null) |
|
|
if (notification != null) |
|
|
{ |
|
|
{ |
|
|
if (notification.HasValue || notification.ErrorType == BindingErrorType.Error) |
|
|
if (notification.HasValue || notification.ErrorType == BindingErrorType.Error) |
|
|
{ |
|
|
{ |
|
|
Value = notification.Value; |
|
|
instance.Value = notification.Value; |
|
|
_owner.Changed(this); |
|
|
instance._owner.Changed(instance); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (notification.ErrorType != BindingErrorType.None) |
|
|
if (notification.ErrorType != BindingErrorType.None) |
|
|
{ |
|
|
{ |
|
|
_owner.Error(this, notification); |
|
|
instance._owner.Error(instance, notification); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
Value = value; |
|
|
instance.Value = newValue; |
|
|
_owner.Changed(this); |
|
|
instance._owner.Changed(instance); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (Dispatcher.UIThread.CheckAccess()) |
|
|
if (Dispatcher.UIThread.CheckAccess()) |
|
|
{ |
|
|
{ |
|
|
Signal(); |
|
|
Signal(this, value); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
Dispatcher.UIThread.Post(Signal); |
|
|
// To avoid allocating closure in the outer scope we need to capture variables
|
|
|
|
|
|
// locally. This allows us to skip most of the allocations when on UI thread.
|
|
|
|
|
|
var instance = this; |
|
|
|
|
|
var newValue = value; |
|
|
|
|
|
|
|
|
|
|
|
Dispatcher.UIThread.Post(() => Signal(instance, newValue)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|