[Bug]: Filter is preventing empty change notifications despite "suppressEmptyChangeSets: false" on Connect
Describe the bug 🐞
Subscribe callback will not be called if Filter removes all entries from a source cache on its initial load despite "suppressEmptyChangeSets: false" being set on Connect.
Step to reproduce
var sourceCache = new SourceCache<Item, int>(p => p.Id);
sourceCache.Connect(suppressEmptyChangeSets: false)
.Filter(x => false)
.Bind(out items)
.Subscribe(x =>
{
Console.WriteLine($"Got {items.Count} results");
});
Expected behavior
Subscribe's onNext and onCompleted should trigger even if the Filter results in no entries when suppressEmptyChangeSets is set to false on Connect.
DynamicData Version
7.9.4
Unfortunately the limitation of suppressEmptyChangeSets is that it can only suppress the empty notifications for the connect method and subsequent operators.
The alternative is to apply the NotEmpty operator after Filter.
var sourceCache = new SourceCache<Item, int>(p => p.Id);
sourceCache.Connect(suppressEmptyChangeSets: false)
.Filter(x => false)
.NotEmpty()
.Bind(out items)
.Subscribe(x =>
{
Console.WriteLine($"Got {items.Count} results");
});
I tried to do what you suggested, and if I'm understanding it correctly, that's the opposite of what I need. I don't want to suppress the empty notification. If my initial load is empty, I expected Subscribe to be hit because suppressEmptyChangeSets is set to false on Connect. Using Filter, even if it's not filtering out any entries, is preventing this.
I thought it might be related to this issue https://github.com/reactivemarbles/DynamicData/issues/581
Doh, I misread and now see what you mean.
I have to say I wish I never ever supressed notifications in the first change and instead allowed consumers to take control to filtering out empty changes. The reason I will not completely remove this feature is in many existing systems, performance and behaviour would be badly affected.
In this case as it's a static filter I am sure it will be straight forward to allow the first time notification through even when empty. However it will probably need careful consideration before jumping in and changing it,
@MagneticLlama .Filter() has its own suppressEmptyChangeSets parameter that can be used to resolve this issue.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.