Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is ObservableCollection<T> suitable in non UI scenarios

I'm not very familiar with ObservableCollection but implementing it seems to provide me with a convenient way of updating a custom collections state based on any add/remove/replace/clear operation.

However, the examples I've looked at typically reference it in the context of WPF/WinForms data binding.

Does implementing it bring any unwanted overhead/dependencies that I should be wary of, ie. in my scenario (simply updating extended state which I have added to the collection based on adds/removes etc.) would it be better to just implement Collection or similar and update the extended state by overriding each add/remove/replace/clear operation?

like image 904
Chris Avatar asked Sep 05 '25 20:09

Chris


1 Answers

The reason ObservableCollection is more often than not associated with UI is because of the flexibility it provides in updating the view if you are using MVVM pattern. Having said that I see no reason it should prevent you from using it in non-UI code. Please refer 1 for perfromance related information.

like image 107
Sandeep G B Avatar answered Sep 09 '25 01:09

Sandeep G B