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

Introduce app.timer #4091

Merged
merged 9 commits into from
Dec 16, 2024
Merged

Introduce app.timer #4091

merged 9 commits into from
Dec 16, 2024

Conversation

falkoschindler
Copy link
Contributor

@falkoschindler falkoschindler commented Dec 11, 2024

This PR implements one of our most-wanted feature requests #3225, an API for timing UI-independent function calls.

The current draft can be tested like this:

import time
from nicegui import app, ui

timer = app.timer(0.5, lambda: print(time.time()))
ui.button('Start', on_click=timer.start)
ui.button('Stop', on_click=timer.stop)
ui.switch('Running').bind_value(timer, 'running')

ui.run()

Open tasks:

@falkoschindler falkoschindler added the enhancement New feature or request label Dec 11, 2024
@falkoschindler falkoschindler added this to the 2.9 milestone Dec 11, 2024
@falkoschindler falkoschindler marked this pull request as ready for review December 12, 2024 08:38
@falkoschindler falkoschindler requested a review from rodja December 12, 2024 08:39
Copy link
Member

@rodja rodja left a comment

Choose a reason for hiding this comment

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

Looks good. I just modified the app.timer test a little bit. It was too similar to the ui.timer test on an auto-index page.

@falkoschindler falkoschindler merged commit b51e70b into main Dec 16, 2024
8 checks passed
@falkoschindler falkoschindler deleted the app-timer branch December 16, 2024 16:57
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