Wouterdek/NodeNetwork

Observe Nodes collections

jbltx opened this issue · 2 comments

jbltx commented

Sorry for disturbing, I am not familiar with ReactiveUI concepts and I was wondering how I can observe changes in the NetworkViewModel.Nodes and NetworkViewModel.SelectedNodes ?

I have a Node class and I store all Node instances in an ObservableCollection (which is handy to use with WPF bindings). I have created a custom NodeViewModel which contains a reference to a Node instance. So my workflow should be to observe the NetworkViewModel collections in order to update my own ObservableCollection behind it.

Based on what I read there, I have tried this at MainWindow initialization, but both delegates OnNodeChanged and OnNodeSelectionChanged are never called :

NodeNetwork = new NetworkViewModel();
NodeNetwork.Nodes.Connect().ForEachItemChange(OnNodeChanged);
NodeNetwork.SelectedNodes.Connect().QueryWhenChanged(OnNodeSelectionChanged);

Thank you !

You might be missing .Subscribe() behind your calls.

jbltx commented

Ah yes, thank you for the quick answer !