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

Beginnings of typed accessors for client data and outputs #719

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jcheng5
Copy link
Collaborator

@jcheng5 jcheng5 commented Aug 30, 2023

This will be necessary for plotly automatic resizing, I believe

Comment on lines +152 to +153
def width(self):
return self._input[f".clientdata_output_{self._id}_width"]()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of implementing individual functions, it might be better to implement a __getattr__ method. That would provide a place to handle outputs that don't exist yet.

Another useful thing with a __getattr__ method is that it could return reactive.Value object itself, instead of only providing a way to invoke () on the object. Although... that could also be accomplished @property decorator -- and using that decorator on each individual item would also allow more specific typing, like Value[bool].

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the __getattr__ due to the inability to type or document each value (right?). The @property could work though. I don't love that reactive.Value exposes .set() that doesn't actually work, but the other methods on Value could be helpful.

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.

None yet

2 participants