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
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:
Other information (e.g. stacktraces, related issues, suggestions how to fix)
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
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...
Most helpful comment
@OzerOzdemir sorry it took so long, but got it working again.