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

Multicasting of page-scoped content #3968

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

aranvir
Copy link

@aranvir aranvir commented Nov 9, 2024

PR for #3828

As discussed there added an iterator to app for yielding clients based on path. Also added documentation (at Page and ElementFilter since it kinda applies to both of them). Added a test.

I was also experimenting a bit with adding a wrapper or context manager as in my initial example, but I think @falkoschindler is right: an iterator is cleaner and then the developer can just do what they want with it.

E.g., in my original example

    def update_clock():
        def _update():
            for element in ElementFilter(kind=ui.label, marker='clock'):
                element.text = time.strftime('%H:%M:%S')
        with_clients(OTHER_PAGE_ROUTE, _update)

versus now

    def update_clock():
        for client in app.clients(OTHER_PAGE_ROUTE):
            with client.content:
                for element in ElementFilter(kind=ui.label, marker='clock'):
                    element.text = time.strftime('%H:%M:%S')

@falkoschindler falkoschindler added the enhancement New feature or request label Nov 11, 2024
@falkoschindler falkoschindler requested review from falkoschindler and removed request for rodja November 11, 2024 15:07
@falkoschindler falkoschindler added this to the 2.6 milestone Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants