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

Replace check_interval for JavaScript requests with asyncio event #2827

Merged
merged 1 commit into from
Apr 6, 2024

Conversation

falkoschindler
Copy link
Contributor

@falkoschindler falkoschindler commented Apr 5, 2024

This PR solves one aspect of issue #2482 by replacing the 0.01s loop with asyncio events.

To verify everything is still working, I experimented with the following demo code:

def alert():
    ui.run_javascript('alert("Hello!")')

async def get_date():
    time = await ui.run_javascript('Date()')
    ui.notify(f'Browser time: {time}')

async def fail():
    await ui.run_javascript('fail()')

ui.button('fire and forget', on_click=alert)
ui.button('receive result', on_click=get_date)
ui.button('timeout', on_click=fail)

Note that I didn't mark every single method parameter as DEPRECATED. I only marked the root implementation, which is called by all derived methods. Similarly, I only added a warning once. I even removed a duplicate marker and a warning for the deprecated respond parameter.

@rodja rodja merged commit ea59b94 into main Apr 6, 2024
7 checks passed
@rodja rodja deleted the check-interval branch April 6, 2024 01:21
@rodja
Copy link
Member

rodja commented Apr 6, 2024

I love it!

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.

None yet

2 participants