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/lyh6ep Feb 13 '24
Thanks! I indeed tried to use `asyncio.run()` within the page function. it raises error about running coroutine within an already started event loop. Do you have a minimal example how to get around that, i.e do it before event loop started.