emilhe / dash-extensions

The dash-extensions package is a collection of utility functions, syntax extensions, and Dash components that aim to improve the Dash development experience
https://www.dash-extensions.com/
MIT License
417 stars 59 forks source link

Enhance `DashBlueprint.register()` to accept custom PrefixIdTransform instances in `prefix` param #321

Closed andressommerhoff closed 5 months ago

andressommerhoff commented 5 months ago

Context: Before this commit, the prefix parameter of DashBlueprint.register() could only accept a string, which would then be used to create and register a default PrefixIdTransform instance in the transforms list of the blueprint. This behavior restricted the flexibility as it only utilized the standard PrefixIdTransform 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 the prefix parameter of DashBlueprint.register(), as it defaults to using the standard PrefixIdTransform. 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 the PrefixIdTransform created by register().

Solution: This commit enhances the functionality of DashBlueprint.register() by allowing the prefix parameter to accept either a string or a custom PrefixIdTransform instance. This change introduces the following improvements:

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 of PrefixIdTransform, such as custom escape functions, are fully usable in all scenarios, supporting complex application architectures more effectively.

andressommerhoff commented 5 months ago

Hi @emilhe! I noticed that the unit tests failed due to a timeout. Do you know why? It's possible that a test server was down and could not be reached. I would like to retry the test, but I don't see the option. Perhaps I don't have the necessary permissions?

emilhe commented 5 months ago

This seems like a reasoanble extension. I agree that the test failure doesn't seem to be related to the code changes.