Skip to content
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

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

Merged
merged 1 commit into from
May 4, 2024

Conversation

andressommerhoff
Copy link
Contributor

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:

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

… instances in `prefix` param

**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:

- **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 of `PrefixIdTransform`, such as custom escape functions, are fully usable in all scenarios, supporting complex application architectures more effectively.
@andressommerhoff
Copy link
Contributor Author

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
Copy link
Owner

emilhe commented May 4, 2024

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

@emilhe emilhe merged commit 2e10e8b into emilhe:master May 4, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants