Background Task Example

Hi,

I just want to share a very simple example of how i learned how use Background tasks in anvil.
Besides just triggering a background task, this example uses local storage to store the background task id, which means that the user can refresh the page, or close and come back at a later time.

I guess there are many ways to achieve this so feel free to come with ideas of improvements :slight_smile:

6 Likes

Very nice. I was just working on some integration with localStorage and sessionStorage caching, this is a great use case.

Did you know that you can send the task object to the client?
This gives you options for getting information from the task while it is running as well as getting the return value from the task.

2 Likes