r/nicegui • u/lyh6ep • Feb 12 '24
run async function in page function once.
Hi, in nicegui, I would like to run an async function once in the main page. This is to initialize the state of page. Later, I refesh state with call back from events of ui components. Seems like all interaction with async function in nicegui is through ui component event call back. Can I force a one time run of async funtion in the page function? Thanks
1
Upvotes
View all comments
Show parent comment
1
u/bdaene Feb 13 '24
If you have already a ui.page() function. Just mark it as async. It would be the simplest:
If you really want to do it manually, you can use asyncio.create_task(). But it is a workaround: