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

Allow watch methods to be private #2382

Closed
willmcgugan opened this issue Apr 26, 2023 · 1 comment · Fixed by #2442
Closed

Allow watch methods to be private #2382

willmcgugan opened this issue Apr 26, 2023 · 1 comment · Fixed by #2442
Assignees
Labels
enhancement New feature or request Task

Comments

@willmcgugan
Copy link
Collaborator

It should be possible for watch methods to be private.

If there is a _watch_* reactive, it should take precedence over the watch_* version.

This will allow us to hide them from the docs.

@davep davep added enhancement New feature or request Task labels Apr 26, 2023
@davep davep self-assigned this May 1, 2023
davep added a commit to davep/textual that referenced this issue May 1, 2023
This change allows for private watch methods. By convention they start with
an underscore. If a reactive or var has a private watch method, it will be
used in preference to a public watch method.

With this change it becomes easier to have a private reactive/var whose
watcher is also private. For example:

    _counter = var(0)
    """This is a private counter, it won't appear in the docs."

    ...

    def _watch__counter(self) -> None:
        """Watch _counter, but don't appear in the docs either."
        ...

See Textualize#2382.
@davep davep linked a pull request May 1, 2023 that will close this issue
@github-actions
Copy link

github-actions bot commented May 1, 2023

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants