-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
Describe the bug
The ReactiveObject.DelayChangeNotifications() method does not delay the firing of PropertyChanged events. (Please note ReactiveObject.SuppressChangeNotifications() does suppress them.)
Steps To Reproduce
The following C# console app demonstrates the bug. All assertions are expected to pass, but 2 of 3 fail.
using System.Diagnostics;
using ReactiveUI;
class Example : ReactiveObject
{
private int _value;
public int Value
{
get => _value;
set => this.RaiseAndSetIfChanged(ref _value, value);
}
}
class Program
{
static void Main(string[] args)
{
var obj = new Example();
var changeEvents = 0;
obj.PropertyChanged += (s, e) => changeEvents++;
using (obj.DelayChangeNotifications())
{
obj.Value = 1;
obj.Value = 2;
Debug.Assert(changeEvents == 0, "Property change raised during delay");
}
Debug.Assert(changeEvents < 2, "Property change not deduped");
Debug.Assert(changeEvents != 0, "Property change not raised");
}
}Expected behavior
Similar to how ReactiveObject.SuppressChangeNotifications() affects property changed events and ReactiveObject.DelayChangeNotifications() delays and removes duplicate change events from the ReactiveObject.Changed observable. I expect:
- No property changing and changed events will be raised between the call of
ReactiveObject.SuppressChangeNotifications()and the disposing of the returnedIDisposable. - When the
IDisposableis disposed of, any delayed changing and changed events will be raised - Changing and changed events that are delayed will be deduplicated so that if a property is changed more than once during the delayed time, only one property change event will be raised for it.
Environment
- OS: Windows Pro
- Version 10.0.18363
- Device: Dell Vostro 7590
- ReactiveUI: v11.3.1
- .NET Framework: v4.7.2