-
-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove from transform many with projection #265
Remove from transform many with projection #265
Conversation
I think I have worked it out. In TansformMany.cs you need to change the following code: return _source.Transform(item => new ManyContainer(_manyselector(item).ToArray()), true)
.Select(changes => new ChangeSet<TDestination>(new DestinationEnumerator(changes, _equalityComparer), qualityComparer))
.NotEmpty(); to return Observable.Create<IChangeSet<TDestination>>(observer =>
{
//NB: ChangeAwareList is used internally by dd to capture changes to a list and ensure they can be replayed by subsequent operators
var result = new ChangeAwareList<TDestination>();
return _source.Transform(item => new ManyContainer(_manyselector(item).ToArray()), true)
.Select(changes =>
{
var destinationChanges = new ChangeSet<TDestination>(new DestinationEnumerator(changes, _equalityComparer));
result.Clone(destinationChanges, _equalityComparer);
return result.CaptureChanges();
})
.NotEmpty()
.SubscribeSafe(observer);
}
); Also void Clone<T>(this IList<T> source, IChangeSet<T> changes, IEqualityComparer<T> equalityComparer = null) and inside that method change Clone(source, item, changes.EqualityComparer); to Clone(source, item, equalityComparer ?? EqualityComparer<T>.Default); With these changes, your unit tests pass, which means you can remove the equality comparer from the change set |
Awesome! I'll revert my commit and proceed with your proposal! Thanks a lot! |
…mMany instead of using IChangeSet
/// or | ||
/// changes | ||
/// </exception> | ||
public static void Clone<T>(this IList<T> source, IChangeSet<T> changes, IEqualityComparer<T> equalityComparer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added an overload instead of an optional parameter because of https://github.com/dchaib/DynamicData/blob/e4e0327fd38c909f293e1bd9731049fdd78a73e0/src/DynamicData/List/ObservableListEx.cs#L1246
Let me know if I should fix this differently!
Should Should the equality comparer be passed in more cases to the
|
Yes, good spot |
I would recommend incrementing the number of the minor in version.json in the root directory before merging this commit |
@RolandPheasant do you know how I can trigger |
RemoveMany is not produced by the transform many operator |
Thanks, that explains why I couldn't figure out how to produce it. :) Then, I guess I'm done as far as I'm concerned. |
Just bump the version.json minor version would be the last thing |
I agree with @glennawatson about the minor version. Please bump then then I will merge this PR |
Done! |
What kind of change does this PR introduce?
Bug fix for #264
What is the current behavior?
When removing an item from a
SourceList
with aTransformMany
transfomartion using a projection, the items are never removed from the "output". See #264 for more details.What is the new behavior?
IChangeSet
now has an equality comparer that can be used when looking for items to remove.What might this PR break?
Hopefully nothing!
Please check if the PR fulfills these requirements
Other information:
This is a draft. If I'm headed in the right direction, I'll refactor and add proper comments when needed.
It might also be necessary to extend the usage of the newly added equality comparer for consistency and maybe fixing other cases.