How can I wait for a server side function call?

I’m using @anvil.server.callable to call a server-side function.

I’d like to do X while the function is being called. e.g. Disabling all components until the spinner stops spinning and a value is returned/changed/updated (this value can be the same).

Is there a "while waiting for the server call" kind of function?

Thanks in advance!

Yep, you can use a context manager (“with” statement).

I’m on my phone, but search the forum for “notification with statement” or “wait for notification” or something to that effect.

1 Like

Neat. It’s actually in the docs:

https://anvil.works/docs/client/python/alerts-and-notifications#notifications

See the parts with with.

As long as “do X” is “display a Notification”, this should work.

If “do X” is something else, then you might consider a Background Task.

2 Likes

Good point. I see that the OP mentioned displaying a message and “disabling user input…etc” which is why I gave that particular suggestion.

Perfect. Many thanks for you help!

Thanks a lot. Much appreciated.