Skip to content

Conversation

@bruzkovsky
Copy link
Contributor

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

Custom implementation of IReactiveObject does not fire PropertyChanging and PropertyChanged events.
See #2594

What is the new behavior?

IReactiveObjectExtensions.SubscribePropertyChangedEvents and IReactiveObjectExtensions.SubscribePropertyChangingEvents are now public

What might this PR break?
This PR breaks the public API by adding two new public extension methods IReactiveObjectExtensions.SubscribePropertyChangedEvents and IReactiveObjectExtensions.SubscribePropertyChangingEvents are

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features) -> API tests have been updated
  • Docs have been added / updated (for bug fixes / features) -> Added XML docs

Other information:

Matthias Bruzek added 2 commits June 1, 2021 19:57
- 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
- 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
var disp1 = fixture.Bind(vm, view, x => x.JustADecimal, x => x.SomeTextBox.Text, (IObservable<Unit>?)null, null);

Assert.Equal(vm.JustADecimal.ToString(CultureInfo.InvariantCulture), view.SomeTextBox.Text);
Assert.Equal(vm.JustADecimal.ToString(CultureInfo.CurrentCulture), view.SomeTextBox.Text);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests were failing on my machine, because here in Austria we have comma "," as decimal separator. I suppose this now runs on every machine, but I'll revert it if breaks something

}

Assert.Equal(approvedPublicApi, receivedPublicApi);
Assert.Equal(approvedPublicApi.Trim(), receivedPublicApi);
Copy link
Contributor Author

@bruzkovsky bruzkovsky Jun 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why my VS keeps adding a blank line at the end of the approval files when saving, but with this the tests are green.

@bruzkovsky bruzkovsky marked this pull request as ready for review June 1, 2021 18:18
@glennawatson glennawatson changed the title Fix/2594 subscribe property changed Fix: Allow IReactiveObject to access subscription extensions Jun 2, 2021
@glennawatson glennawatson merged commit 4f94c6b into reactiveui:main Jun 2, 2021
@glennawatson
Copy link
Contributor

Thanks for the PR, I will do a release in the next day or so.

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants