-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[REF-2523] Implement new public Component API #3203
Conversation
add_imports (dict str: list of str or importvar) add_hooks (list of str) add_custom_code (list of str) These functions are treated specially in that they don't have to call `super()`, ever. Internally the Component will walk up all of the base Component classes and call each `add_*` method and collect the return values. All the downstream user has to do is implement these add_* functions and return the value they want to add.
return {} | ||
|
||
def add_hooks(self) -> list[str]: | ||
"""Add hooks inside the component function. |
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.
Maybe this can include an example of how it's used in practice (along with the other ones) for the autogenerated API docs
@@ -932,6 +989,30 @@ def _has_event_triggers(self) -> bool: | |||
return True | |||
return False | |||
|
|||
@classmethod | |||
def _iter_parent_classes_with_method(cls, method: str) -> Iterator[Type[Component]]: |
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.
Does this affect compile time noticeably at all?
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.
on reflex-web, there is no change in compile time 😅, i expect this iter operation to be quite fast; although it does have to look at all parent classes in the mro chain, it doesn't actually call the method unless it's been defined, and it only calls each unique method once.
add_imports (dict str: list of str or importvar)
add_hooks (list of str)
add_custom_code (list of str)
These functions are treated specially in that they don't have to call
super()
, ever. Internally the Component will walk up all of the base Component classes and call eachadd_*
method and collect the return values.All the downstream user has to do is implement these add_* functions and return the value they want to add.