DeclarativeProperty async optimizations

This commit is contained in:
2023-10-31 14:58:22 +01:00
parent 63a450fc5f
commit 17df1b45c2
11 changed files with 34 additions and 43 deletions

View File

@@ -11,13 +11,13 @@ public sealed class DistinctUntilChangedProperty<T> : DeclarativePropertyBase<T>
AddDisposable(from.Subscribe(Handle));
}
async Task Handle(T next, CancellationToken cancellationToken = default)
private Task Handle(T next, CancellationToken cancellationToken = default)
{
if (_comparer is { } comparer)
{
if (comparer(Value, next))
{
return;
return Task.CompletedTask;
}
}
else if (
@@ -25,10 +25,10 @@ public sealed class DistinctUntilChangedProperty<T> : DeclarativePropertyBase<T>
|| (Value?.Equals(next) ?? false)
)
{
return;
return Task.CompletedTask;
}
_firstFire = false;
await SetNewValueAsync(next, cancellationToken);
return SetNewValueAsync(next, cancellationToken);
}
}