feat: collection-modification broadcast #10
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added a general-purpose broadcast for all modifications to auto collections.
In some cases, a user will only want to know that a collection has been modified, without regard to what the modification was. (An example use case: saving a list of high scores to disk whenever the list is modified, whether that's adding a new score or replacing an old one.)
In such cases it is cumbersome to subscribe to all notifications, as the callbacks have different signatures. Currently, the user must do:
(Granted, the
OnClear()callback could be a direct call toSaveHighScoressince the signature matches, and perhaps the Added/Removed callbacks could be condensed into one, but the structure of the code becomes less clear as these elisions are made.)This PR adds a general-purpose modification callback to all auto-collections:
I've also updated some xmldocs comments to match comparable comments on other collections, updated a couple test names to be consistent, and updated the clear tests for
AutoMapandAutoSetto verify that they only broadcast when the collection is non-empty (similar to the tests forAutoList).