Reactiveui: ReactiveTableViewSource does not update Table View on changing data

Created on 7 Nov 2018  路  4Comments  路  Source: reactiveui/ReactiveUI

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)

bug consumer-experience outdated

Most helpful comment

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

All 4 comments

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

https://github.com/reactiveui/ReactiveUI/commit/a853deadc5245a825ca54462859523f45f8b6ba8#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);

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.

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

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

Was this page helpful?
0 / 5 - 0 ratings