New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] this.RaiseAndSetIfChanged does not trigger PropertyChanged event for generic IReactiveObject #2594
Comments
I'll have a look at this one after I get my massive .net 5 branch sorted. Will do it as part of a Fody refactor I did a while back and get that in. |
Also thanks for providing the sample, that always helps. |
I just added screenshots of the sample app. I figured that's easier to see than cloning and debugging.
You're welcome. I can't tell you how many "bugs" I've identified in various libraries where I try to make a sample project to reproduce it, find that I can't, and eventually realize it's not a bug and I'm doing something stupid in my main project. I always feel better about reporting something if I can reproduce it in a simple project. P.S. I'm still fairly new to Dynamic Data, so I hope you'll forgive me if some of my observables are less than optimal. |
Hi, I have the same problem after upgrading to 11.5.35 from 10.5.43 |
@glennawatson @RLittlesII can I be of any help with fixing this? This issue is pressing for us, because after updating to ReactiveUI 13.3.1 none of the Xamarin Forms bindings that go directly to the PageViewModel are working. This is because we use MvvmCross, and they require us to extend When I look at the
This is the implementation of the extension method: ReactiveUI/src/ReactiveUI/ReactiveObject/IReactiveObjectExtensions.cs Lines 215 to 221 in 92df299
Here is the implementation in
And finally, where the event should be propagated (line 375 checks if the Lazy was created with ReactiveUI/src/ReactiveUI/ReactiveObject/IReactiveObjectExtensions.cs Lines 367 to 385 in 92df299
I assume that simply calling |
Looking through it you should be able to make those public. The rationale was due to it accessing a internal state object but it should abstract it for you. It's a breaking change but we have some changes to binding coming that are breaking so now would be a good time for you to make these changes. |
Thanks for the quick reply, I'll fire up a PR! |
- this change enables consumers to implement IReactiveObject and get PropertyChanged and PropertyChanging notifications (which regressed in version 11.4.1) - to get the notifications, one must call this.SubscribePropertyChangedEvents() or this.SubscribePropertyChangingEvents() on the IReactiveObject instance - related: reactiveui#2594
* fix: Change access modifier for SubscribePropertyChangedEvents to public - this change enables consumers to implement IReactiveObject and get PropertyChanged and PropertyChanging notifications (which regressed in version 11.4.1) - to get the notifications, one must call this.SubscribePropertyChangedEvents() or this.SubscribePropertyChangingEvents() on the IReactiveObject instance - related: #2594 * fix: unit tests failing on Device with de_AT culture - there were unit tests failing because they compared string representations of double in the CultureInfo.InvariantCulture format. This was changed to CultureInfo.CurrentCulture to work with the culture of the Device running the tests * fix: approval tests failing because of wrong parameter names * fix: Approval tests fail after saving file which automatically adds blank line Co-authored-by: Matthias Bruzek <matthias.bruzek@opti-q.com>
For the benefit of anybody who stumbles across this issue in the future, this was fixed in version Version 14.1.1. From the commit notes for commit 4f94c6b, we have:
|
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. |
Describe the bug
If a custom
IReactiveObject
(in this example,IReactiveObjectFilter
) callsthis.RaiseAndSetIfChanged(ref _field, value)
, thenRaisePropertyChanging
andRaisePropertyChanged
methods are never called, and thereforePropertyChanging
andPropertyChanged
events are not triggered.While
IReactiveObjectFilter.WhenAnyValue(x => x.ShouldFilter)
receives notifications whenthis.RaiseAndSetIfChanged
is called,SourceList<IReactiveObjectFilter>.Connect().AutoRefresh(x => x.ShouldFilter)
does not receive notifications, sincePropertyChanged
is never called.Steps To Reproduce
https://github.com/timothylcooke/IReactiveObjectExample.git
demonstrates the behavior. This is a WPF project that shows a window with aTabControl
. Both Tabs shows aMyUserControl
. EachMyUserControl
has a binding to aMyViewModel
, which has aSourceList<IFilter>
of filters (toggled with the CheckBoxes). In the first tab, theIFilter
objects areReactiveObjectFilter
objects, and in the second tab, theIFilter
objects areIReactiveObjectFilter
objects. Whether theIFilter
extendsReactiveObject
or implementsIReactiveObject
determines if thePropertyChanged
event is triggered, and therefore if theSourceList<IFilter>.Connect().AutoRefresh(x => x.ShouldFilter)
triggers updates.Expected behavior
If I implement
IReactiveObject
and callthis.RaiseAndSetIfChanged()
, it should callRaisePropertyChanged
.Screenshots
In the screenshots below, the key difference is that in the first screenshot, where the
IFilter
objects inherit fromReactiveObject
, we see the lineFilter… PropertyChanged("ShouldFilter") fired.
This ripples down and ends up triggeringfiltersSource.Connect().AutoRefresh(x => x.ShouldFilter)
, and in turn updates thecurrentFilters
collection. In the second screenshot, where theIFilter
objects implementIReactiveObject
,PropertyChanged
is never called on the filter, and thereforefiltersSource.Connect().AutoRefresh(x => x.ShouldFilter)
is never fired. This leaves ourcurrentFilters
collection unmodified, and therefore does not filter any items in the Filtered Names list.Environment
Additional context
N/A
The text was updated successfully, but these errors were encountered: