Monday, October 31, 2016

ReactiveList: ObservableCollection on steroids

If you ever build an MVVM style application before(using WPF, Silverlight, UWP,…) you probably used the ObservableCollection class.  It implements the INotifyCollectionChanged interface and can be seen as the counterpart of INotifyPropertyChanged. Through this interface the ObservableCollection notifies its subscribers about items being added, deleted, moved, …

Unfortunately the ObservableCollection is rather limited in it’s behavior and doesn’t fit well in a truely observable architecture. Luckily the ReactiveUI framework and more specificly the ReactiveList solve exactly this problem…

image

Let’s describe a scenario I had to build that was hard to do using ObservableCollection and a walk-in-the-park with ReactiveList:

In our application we have to show a list of alerts and update the list when new alerts arrive. However alerts can arrive at a high pace and we don’t want to update the UI continuously but only when at least 5 alerts are raised.

In our original implementation we used a pull based mechanism combined with a timer to load the alerts every 30 seconds from the database.  Let’s see how easy it is to do the same thing with ReactiveList without having to fallback to polling and storing all data:

1 comment:

Thunderrise said...

Thank you for information. It's quite clearly to understand. Moreover, for people who would like to focus their attention on the app development costs (time and money) and come the mobile market with a quality product like Tinder, I could advise to read this article:Thunderrise Go aheard, it's very practical to use!