xpaulbettsx/ReactiveUI — pull request #76 by jlaanstra (2012-08-30 18:33:55+00:00)
Title: ReactiveCollection issues

Dear Paul,

We are currently using ReactiveUI in a WinRT project and we experienced some issues with ReactiveCollection bound to a Gridview. We experienced reloading of the items when clearing the collection which causes flickering and animations to restart.

Because of the issues we temporarily switched to using ObservableCollection which does not have this issue and I decided to look into the ReactiveCollection class to see what was causing our issues. This pull request is not necessarily meant to be included in ReactiveUI, but more to discuss some changes I made and to improve my understanding of the ReactiveCollection class.

Some of the things I noticed was the difference in notifications fired by the ObservableCollection class and the ReactiveCollection class. I'm not sure if these differences are intentionally or not. Also the code that should disable change notifications doesn't seem to work since all notifications were fired normally. I noticed there is actually also an issue at the issue tracker, which has something to do with change notifications. Also the reset notification was fired twice because the Reset() method is automatically called when change notifications are reenabled and almost everywhere in the code where this happens the Reset() method is called for a second time. Therefore I decided to remove the reset call when notifications are reenabled since the comments do not mention this effect.

Another thing I noticed was the code in the ClearItems method. The reason why base.ClearItems() is not called is not completely clear to me. My initial understanding of the while loop removing the items is to fire the ItemsRemoved observable. Is this correct since the suppressing of notifications would suggest this should not happen.

And how about the Changing and Changed observables? Their function is not entirely clear to me. They just seem to aggregate events already available via the other observables. I also noticed that Changed was not including the cleared observable while Changing was including the aboutToClear observable.

Since you are breaking backwards compatibility with RxUI v4, maybe this is a good time to also do some cleanup and fixing in this class. Have you ever considered not inheriting the ObservableCollection class? That would probably give you much better control of the change notifications.

I hope you can answer some of my questions and I'm also glad to help improving the ReactiveCollection class. Looking forward to hear what you think about it.

Regards,

Johan