Convert Reactive List To Dynamic Data.

What is ReactiveList

A built-in class come along with ReactiveUI to replace ObservableCollection. It is similar to a list but has the power of Rx.

But it is clumsy, buggy and becoming unstable. People who using it may encounter many bugs, app crashing and it’s quite not a thread-safe.

What is Dynamic Data

DynamicData is reactive collections based on Rx.Net, provide an API which allows the consumers to observe changes and act on those changes. The changes are accessible via .Connect(). The idea is to create the data source first and bind it later.

Creating

Question:

  • SourceList vs SourceCache, which one is better?

Answer:

  • SourceCache has every advantage over SourceList. It can notifies when update which SourceList has no idea how.
  • But the cache requires the no duplicate collection and unique ID. If we not sure our list will have duplicate items or when it’s quite hard to maintain the ID, just use SourceList.

Side Effects

Many people have used this and approved, it’s very stable.

Consider both of them on every aspect, we can easily decide to replace ReactiveList with DynamicData. A common mistake a lot of users make is trying to expose DynamicData classes to the world, eg: pass the sourceList as the parameter.

How to convert ReactiveList to Dynamic Data

We can follow the following pattern:

Notes:

  • The binding property ReadOnlyObservableCollection from sourceList can only be used for binding.
  • We use IObservableList property to pass around.
Whatsapp: +84932129990