Skip to content

[Bug]: BindTo pushes data to old nested objects #4214

@lfpraca

Description

@lfpraca

Describe the bug 🐞

When using BindTo to hack a two way binding in a view that doesn't implement IViewFor, if BindTo is set up to observe on a nested property to sync to a view property and then back to push to this nested property on a separate BindTo, when the nesting property changes (e.g. NestedObj in MyViewModel.NestedObj.SomeText), the BindTo feeding back to the SomeText property pushes to SomeText in both the new and old NestedObj instances (the new one is pushed to first, then the old one, which I find quite surprising).

This is a problem if something is listening to changes on the old NestedObj and thinks something there has changed, when in reality it was abandoned, and no changes to it should have actually happened.

Using subscribe and manually assigning to the property does not trigger this issue.

Step to reproduce

  1. Start the WPF application
  2. Click on the 'Fetch Data' button
  3. See the 'Changed in ...' text box popping up twice, for two distinct NestedObject instances
  4. Comment the BindTo lines and uncomment the Subscribe lines
  5. Repeat 1 and 2
  6. See the 'Changed in ...' text box popping up only once, for the new NestedObject instance

Reproduction repository

https://github.com/lfpraca/ReactiveUiBindToBugRepro

Expected behavior

BindTo should push values to the new destination only

Screenshots 🖼️

No response

IDE

No response

Operating system

Windows

Version

11

Device

No response

ReactiveUI Version

22.3.1

Additional information ℹ️

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions