0

ReactiveUI 3.2.0.0 used to have CollectionExtensions class that implemented ObserveCollectionChanged() method. Where is the method now under ReactiveUI 4.0.2?

    private readonly ReactiveCollection<string> _sourceItems = new ReactiveCollection<string>();
    private readonly ReactiveCollection<SelectableDataItem<string>> _selectableItemsView = null;
    private readonly ReactiveCollection<SelectableDataItem<string>> _selectedItemsView = null;
    private readonly ReactiveCollection<string> _selectedDataView = null;

    ....


        this._sourceItems.ChangeTrackingEnabled = true;

        this._selectableItemsView =
            this.SourceItems.CreateDerivedCollection<string, SelectableDataItem<string>>(i => new SelectableDataItem<string>(i) { IsSelected = true, });
        this._selectableItemsView.ChangeTrackingEnabled = true;
        this._selectedItemsView =
            this._selectableItemsView.CreateDerivedCollection<SelectableDataItem<string>, SelectableDataItem<string>>(
            i => i,
            f => f.IsSelected,
            (i1, i2) => 0
            );
        this._selectedItemsView.ChangeTrackingEnabled = true;
        this._selectedDataView =
            this._selectableItemsView.CreateDerivedCollection<SelectableDataItem<string>, string>(i => i.Data, f => f.IsSelected, (i1, i2) => 0);
        this._selectedDataView.ChangeTrackingEnabled = true;
AKornich
  • 682
  • 5
  • 16
  • ReactiveUI's `ReactiveCollection` class no longer inherits from .NET's `ObservableCollection`. What goal are you trying to accomplish? – Ana Betts Nov 27 '12 at 07:55
  • I was planning to upgrade ReactiveUI 3.2 to 4.0.2 and I have A ReactiveCollectionView type implemented which is read-only, filterable, and sortable wrapper around a ReactiveCollection. The view relies on ObserveCollectionChanged() to get a notification from the wrapped collection about NotifyCollectionChangedAction.Reset so the wrapper can refresh itself. – AKornich Dec 04 '12 at 19:39

1 Answers1

0

Upgrade to ReactiveUI 4.1, and use someCollection.CreateDerivedCollection - all of the work has been done for you already :)

Ana Betts
  • 73,868
  • 16
  • 141
  • 209
  • Paul, thank you very much for the help. I'll try it out tonight. Is CreateDerivedCollection(...) capable of producing a read-only wrapper? Is there any conceptual review document describing this cool an powerful framework? – AKornich Dec 04 '12 at 22:24
  • Ok, I did upgrade to v4.1 and using CreateDerivedCollection(...) to produce derived reactive collections. One thing, I noticed, is it seems that the source collections ItemChanged does not get triggered, hence any change/update of an item within source collection are not reflected within the derived one. Any idea what I could be doing wrong? BTW, adding items to the source is reflected within the derivative. – AKornich Dec 04 '12 at 22:54
  • @AKornich ItemChanged only fires if you have ChangeTrackingEnabled set to true – Ana Betts Dec 05 '12 at 01:00
  • Paul, thanks! However, it does not seem to help. Here is my code snippet:
                          private readonly ReactiveCollection _sourceItems = new ReactiveCollection();
            private readonly ReactiveCollection> _selectableItemsView = null;
            private readonly ReactiveCollection> _selectedItemsView = null;
            private readonly ReactiveCollection _selectedDataView = null;
    – AKornich Dec 05 '12 at 05:13
  • this._sourceItems.ChangeTrackingEnabled = true; this._selectableItemsView = this.SourceItems.CreateDerivedCollection>(i => new SelectableDataItem(i) { IsSelected = true, }); this._selectableItemsView.ChangeTrackingEnabled = true; – AKornich Dec 05 '12 at 05:19
  • this._selectedItemsView = this._selectableItemsView.CreateDerivedCollection, SelectableDataItem>( i => i, f => f.IsSelected, (i1, i2) => 0 ); this._selectedItemsView.ChangeTrackingEnabled = true; – AKornich Dec 05 '12 at 05:19
  • this._selectedDataView = this._selectableItemsView.CreateDerivedCollection, string>(i => i.Data, f => f.IsSelected, (i1, i2) => 0); this._selectedDataView.ChangeTrackingEnabled = true; – AKornich Dec 05 '12 at 05:20
  • sorry, I could not figure out how to format code in the comments. I just added it formatted to the original question... – AKornich Dec 05 '12 at 05:24