Enhance DashBlueprint.register()
to accept custom PrefixIdTransform instances in prefix
param
#321
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.
Context:
Before this commit, the
prefix
parameter ofDashBlueprint.register()
could only accept a string, which would then be used to create and register a defaultPrefixIdTransform
instance in thetransforms
list of the blueprint. This behavior restricted the flexibility as it only utilized the standardPrefixIdTransform
with no possibility to specify a custom escape function.Problem:
While
PrefixIdTransform
itself does offer the option to specify a custom escape function, this option is lost when using theprefix
parameter ofDashBlueprint.register()
, as it defaults to using the standardPrefixIdTransform
. In many use cases, such as mine, there is a need to skip the prefix modification for specific elements, which was not feasible without implementing a cumbersome workaround. This limitation was due to the inability to use a custom escape function within thePrefixIdTransform
created byregister()
.Solution:
This commit enhances the functionality of
DashBlueprint.register()
by allowing theprefix
parameter to accept either a string or a customPrefixIdTransform
instance. This change introduces the following improvements:Customizability: Developers can now pass a custom
PrefixIdTransform
instance with their own logic for the escape function, allowing for greater control over which components are affected by the prefixing.Flexibility: By enabling the direct use of a customized
PrefixIdTransform
, developers retain the option to specify how and when to apply the escape logic.Reduced Complexity: It eliminates the need for complex workarounds previously required to handle special cases where prefixing should be selectively applied.
Clarity and Maintainability: The prefix machinery more maintainable by directly supporting different configurations of
PrefixIdTransform
.Impact:
This change will significantly enhance the flexibility and usability of
DashBlueprint.register()
for developers needing more control over component ID transformations. It aligns with the principles of extensibility and customization. Additionally, it ensures that the powerful features ofPrefixIdTransform
, such as custom escape functions, are fully usable in all scenarios, supporting complex application architectures more effectively.