Skip to content
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

ReactiveTableViewSource does not update Table View on changing data #1835

Closed
OzerOzdemir opened this issue Nov 7, 2018 · 4 comments · Fixed by #1931
Closed

ReactiveTableViewSource does not update Table View on changing data #1835

OzerOzdemir opened this issue Nov 7, 2018 · 4 comments · Fixed by #1931

Comments

@OzerOzdemir
Copy link

Do you want to request a feature or report a bug?
This is a bug. It is a regression from 8.7.2 (working) to 9.0.1 (not working)

What is the current behavior?
ReactiveTableViewSource does not update the table view when the collection pointed at by "Data" gets modified.

            ViewModel = new ShoppingListViewModel();
            ItemsTableViewSource = new ShoppingListItemsDataSource(ItemsTable) { ViewModel = this.ViewModel };
            ItemsTable.Source = ItemsTableViewSource;

            ItemsTableViewSource.Data = new[]
            {
                new TableSectionInformation<ShoppingListCellViewModel, ShoppingListTableCell>(ViewModel.ShoppingListItems, new NSString("LIST_CELL"), 46,  cell => cell.Initialize())
            };

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
Here is a repro of the problem. This project was created on MacOS with Visual Studio for Mac.
https://1drv.ms/u/s!AKKNNcL3HxjfiOAZ

  1. Please read the README.txt file in the project.
  2. When you build and run the linked project, it RUNS as expected (no bug) since it uses the 8.7.2 package.
  3. After you see it working, update the ReactiveUI package to 9.0.1, and recompile/rerun, this time it will not work.

What is the expected behavior?
If a collection that implements INotifyCollectionChanged updates the collection, ReactiveTableViewSource is expected to update the cells in the UITableView.

What is the motivation / use case for changing the behavior?

Which versions of ReactiveUI, and which platform / OS are affected by this issue? Did this work in previous versions of ReativeUI? Please also test with the latest stable and development snapshot
This is happening on the following configuration:

  • ReactiveUI iOS (9.0.1)
  • iPhone Simulator iOS 12.1
  • Visual Studio for Mac (7.6.11)
  • .Net Core 2.1.2

Other information (e.g. stacktraces, related issues, suggestions how to fix)

@OzerOzdemir
Copy link
Author

OzerOzdemir commented Nov 7, 2018

Here is the debug output from 8.7.2

LogHost: Initializing to normal mode
CommonReactiveSource`4: [#0] SectionInfo changed to ReactiveUI.TableSectionInformation`1[ReactiveListTest.ShoppingListCellViewModel][].
CommonReactiveSource`4: [#0] SectionInfo ReactiveUI.TableSectionInformation`1[ReactiveListTest.ShoppingListCellViewModel][] does not implement IReactiveNotifyCollectionChanged - any added or removed sections will not be reflected in the UI.
CommonReactiveSource`4: [#0] Calling ReloadData()
CommonReactiveSource`4: [#0] IsReloadingData = True
CommonReactiveSource`4: SectionInfo about to change, disposing of any subscriptions for previous SectionInfo.
CommonReactiveSource`4: [#0] Disposed of section info
CommonReactiveSource`4: [#1] SectionInfo changed to ReactiveUI.TableSectionInformation`2[ReactiveListTest.ShoppingListCellViewModel,ReactiveListTest.ShoppingListTableCell][].
CommonReactiveSource`4: [#1] SectionInfo ReactiveUI.TableSectionInformation`2[ReactiveListTest.ShoppingListCellViewModel,ReactiveListTest.ShoppingListTableCell][] does not implement IReactiveNotifyCollectionChanged - any added or removed sections will not be reflected in the UI.
CommonReactiveSource`4: [#1] Calling ReloadData()
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting rows in section 0 = 0
CommonReactiveSource`4: [#1] IsReloadingData = True
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting rows in section 0 = 0
CommonReactiveSource`4: [#1] IsReloadingData = False

And here from 9.0.1

LogHost: Initializing to normal mode
CommonReactiveSource`4: [#0] SectionInfo changed to ReactiveUI.TableSectionInformation`1[ReactiveListTest.ShoppingListCellViewModel][].
CommonReactiveSource`4: [#0] SectionInfo ReactiveUI.TableSectionInformation`1[ReactiveListTest.ShoppingListCellViewModel][] does not implement INotifyCollectionChanged - any added or removed sections will not be reflected in the UI.
CommonReactiveSource`4: SectionInfo about to change, disposing of any subscriptions for previous SectionInfo.
CommonReactiveSource`4: [#0] Disposed of section info
CommonReactiveSource`4: [#1] SectionInfo changed to ReactiveUI.TableSectionInformation`2[ReactiveListTest.ShoppingListCellViewModel,ReactiveListTest.ShoppingListTableCell][].
CommonReactiveSource`4: [#1] SectionInfo ReactiveUI.TableSectionInformation`2[ReactiveListTest.ShoppingListCellViewModel,ReactiveListTest.ShoppingListTableCell][] does not implement INotifyCollectionChanged - any added or removed sections will not be reflected in the UI.
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting rows in section 0 = 0
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting number of sections = 1
CommonReactiveSource`4: Reporting rows in section 0 = 0

Note the change in private void SectionInfoChanged(IReadOnlyList sectionInfo) in https://github.com/reactiveui/ReactiveUI/blob/master/src/ReactiveUI/Platforms/uikit-common/CommonReactiveSource.cs

a853dea#diff-adf99e2de36e239f5fca78def0c29407L198

Previously:

var sectionChanged =
                 (reactiveSectionInfo == null
                     ? Observable<Unit>.Never
                     : reactiveSectionInfo
                     .Changed
                     .Select(_ => Unit.Default))
                     .StartWith(Unit.Default);

Now:

var sectionChanged = notifyCollectionChanged == null ?
                 Observable<Unit>.Never : 
                 notifyCollectionChanged.ObserveCollectionChanges().Select(_ => Unit.Default);

OzerOzdemir referenced this issue Nov 7, 2018
…#1727)

Make these streams more "visible" by exposing them from the adapter. Let the base adapter class do the work of merging the individual streams of each view holder, so the client doesn't have to.
@glennawatson
Copy link
Contributor

Thanks for the detailed issue @OzerOzdemir

I will work on this over the next day or so and see if I can get a solution for you.

Will likely see if I can get a unit test up and running for this situation first and then provide a fix.

@cabauman
Copy link
Contributor

cabauman commented Jan 26, 2019

@OzerOzdemir sorry it took so long, but got it working again.

@OzerOzdemir
Copy link
Author

Verified that the is working now as expected. Much appreciated...

@lock lock bot added the outdated label Jun 24, 2019
@lock lock bot locked and limited conversation to collaborators Jun 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants