-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
Feature: MergeManyChangeSets with Parent Item Comparison #750
Feature: MergeManyChangeSets with Parent Item Comparison #750
Conversation
Codecov Report
@@ Coverage Diff @@
## main #750 +/- ##
==========================================
+ Coverage 64.61% 64.74% +0.13%
==========================================
Files 225 226 +1
Lines 11354 11464 +110
Branches 2318 2335 +17
==========================================
+ Hits 7336 7422 +86
- Misses 3067 3085 +18
- Partials 951 957 +6
|
@RolandPheasant I think this one is now ready to go. Please take a look at your leisure and let me know what you think. |
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.
It's optional whether to action the zero allocation thing or not.
Maybe that would be best done as a distinct task / pr/
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
This PR adds overloads to the Cache verion of
MergeManyChangeSets
that allow an additionalIComparer
parameter that operates on the source type so that priority of the resulting changeset can be based on factors in the source item, and not just child items.Two
IComparer
instance can be provided so that child-based comparisons can be done as a fallback when the source comparison evaluates as the same.Examples
Say there's a mobile app that aggregates movie review web sites and has these basic interfaces:
And the goal is to create an observable changeset that has a review for each movie, but when the movie has been reviewed by multiple critics, it should emit the review from the most popular critic. This is problematic because the Internet is fickle and popularity can change. How can you do such a thing? DynamicData and Rx will come to the rescue.
With this PR, all such a changeset can be created with just a few lines of code:
That's all there is to it! And now
movieReviewCache
will always contain the review of each movie from the most popular critic to have reviewed that movie. For example, it will exhibit some of the following behaviors:Updated
to the review from next most-popular reviewer.Another Example
At this point, you might be wondering "What if two Critics have the same popularity and rate the same movie? I need it to always include the Best/First/Most Recent/etc review in those cases."
Well, there's an overload for that as well. You just need a comparer for the child objects that will be used as a fallback when two parents compare to be the same.
Testing Improvements
Market
andMarketPrice
to be part ofDomain
namespace promote re-use