-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Implement SetItems method in ResourceDictionary #18354
base: master
Are you sure you want to change the base?
Implement SetItems method in ResourceDictionary #18354
Conversation
Public API for review: namespace Avalonia.Controls
{
public class ResourceDictionary : ResourceProvider, IResourceDictionary, IThemeVariantProvider
{
+ public void AddOrUpdateRange(IEnumerable<KeyValuePair<object, object?>> values);
}
} |
This API should be added to the AvaloniaDictionary as well, I would say. Even as a single Reset operation, it still would be better. |
The API review focused on the naming, as we're fine with the behavior. Points:
After some debate, |
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.
LGTM, thank you!
What does the pull request do?
This PR provides a new method to the ResourceDictionary called
AddOrUpdateRange
which allows to batch multiple updates in one go and notify all subscribers about the change at the very end once the resources have been updated.See discussion: #18346
What is the current behavior?
At the moment, adding or updating existing resources are immediately notifying all subscribers about resource changes. In complex application this can become quite expensive and slow when your updating multiple (tens or hundreds) resources by code.
What is the updated/expected behavior with this PR?
When using the
AddOrUpdateRange
methods, the notification of all subscribers happens only once at the end of the method, regardless of the number of updates performed.Checklist
Breaking changes
None.
Obsoletions / Deprecations
None.
Fixed issues
#18346