S
Solara

general

3 what s the best way to implement `push

TTao8/7/2023
3. what's the best way to implement push notification ? is it something like this ? and is it run as an OS thread or a greenlet in eventloop ? ``` @solara.component def Page(): push_notifications = solara.use_reactive([]) def worker(): // infinite loop while True: // wait for some condition // push_notifications.set(...) solara.use_thread(worker)
Mmariobuikhuizen8/7/2023
Yes, this is the best way to do it if //wait for some condition is not based on Solara reactive vars or component args and you have to wait on the next condition again. Note that the worker function needs an argument: cancel: threading.Event
MMaartenBreddels8/7/2023
That’s optional btw

Looking for more? Join the community!