I am evaluating ReactiveExtensions and ReactiveUI for my current project. Both look very promising. However, I just ran into following problem. I have a type called RecordSet that defines a read only property of ReactiveCollection<MyRecordType> called Records. I need to manipulate some properties of every record item to be added to the collection as well as other items that are already in the collection right before the new item is added to the collection. Some of the manipulations are based on total count of the items that are already in the collection but not including the item to be added. I was trying observing _records.BeforeItemsAdded but for some reason OnNext() callbacks invoked “too late” (after items count in the collection already equals to the total number or items that are eventually added to the collection). What is recommended Rx pattern for attacking problem like this?
I am evaluating ReactiveExtensions and ReactiveUI for my current project. Both look very promising.
Share
Don’t you receive the item to update in BeforeItemsAdded? Why not just change that object directly?
Update: Unfortunately, I suspect that there isn’t a way to do this in
BeforeItemsAddedin this version of RxUI, asBeforeItemsAddedalways gets run on the UI thread. In RxUI 4.1 (which will be released soon), this isn’t the case.In the meantime, you might have to do your item fixup before you call
Add.