Skip to content

Conversation

TheGrandUser
Copy link
Contributor

This adds an optional Action onRemoved argument to the ReactiveDerivedCollection class, and a matching Action onRemoved each of the CreateDerivedCollection and CreateDerivedBindingList methods.

If the delegate is given, then it will be called whenever a derived item is removed, as well as for each item when the derived collection as a whole is disposed.

The DerviedCollectionShouldHandleItemsRemoved test is also added and passes, and all prior tests pass.

Fixes #743

@flagbug
Copy link
Member

flagbug commented Oct 29, 2014

onRemoved should probably also be called for each item when the collection resets

@TheGrandUser
Copy link
Contributor Author

Yes, that is handled, since Reset calls internalClear which is one of the places where onRemoved is called. I just forgot to make a test for that case.

@flagbug
Copy link
Member

flagbug commented Oct 29, 2014

Cool, didn't see that, sorry!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if () { not if (), all over

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here is the reason I wish the code style options were part of the project/solution settings rather than the user settings. I caught some of them, but not all.

@TheGrandUser
Copy link
Contributor Author

Oops, ok, I'll fix that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably simplify a lot of this code by just writing:

this.onRemoved = onRemoved ?? (() => {});

@anaisbetts
Copy link
Member

Added a few notes, but this generally looks good

@anaisbetts
Copy link
Member

@TheGrandUser Don't close this! Just make more commits

@anaisbetts anaisbetts reopened this Oct 30, 2014
@TheGrandUser
Copy link
Contributor Author

Oh, I was not aware that was how it worked, being a bit new to git. I've made the new commits.

@anaisbetts
Copy link
Member

@TheGrandUser No worries, it's a common misconception that you have to close and resubmit the PR :)

@anaisbetts anaisbetts merged commit 9e84168 into reactiveui:master Nov 3, 2014
@anaisbetts
Copy link
Member

Great, thanks @TheGrandUser!

@TheGrandUser
Copy link
Contributor Author

Great, hope to see it on NuGet before too long :)

@anaisbetts
Copy link
Member

@TheGrandUser I've got one more major issue to look at (type forwarding for INotifyPropertyChanging) then this will be part of ReactiveUI 6.1

@lock lock bot locked and limited conversation to collaborators Jun 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReactiveDerivedCollection needs to be able to Dispose derived items
3 participants