Explicit status hooks
How to add statuses
to your Job code and then subscribe using the hooks
You can create statuses
in your Job code. This gives you fine grained control over what you want to expose.
It allows you to:
- Show exactly what you want in your UI (with as many statuses as you want).
- Pass arbitrary data to your UI, which you can use to render elements.
- Update existing elements in your UI as the progress of the run continues.
In your Job code
You should create a “status”, which you can then update throughout the Job if you’d like to. You can create more than one status. Each of these will come through to the hook with the latest status and the history for each.
In this case we created just a single status generating-memes
and then updated it. It’s worth noting that you can create as many statuses as you’d like in a single Job and you can update them as many times as you want.
This allows you to fine-grained control over how you report progress and output data from your Job.
Using the React hooks
There are two hooks you can use in your UI to display the Run statuses.
- useEventRunStatuses: get the statuses of a run that was triggered by a specified event
- useRunStatuses: get the statuses of the specified run
useEventRunStatuses
The useEventRunStatuses
hook will give you the statuses and overview data of the first run that is triggered by an event.
This component will show the details of a Run and the status of each task in the Run:
useRunStatuses
The useRunStatuses
hook will give you the statuses and overview data of a specific Run.
This component will show the details of a Run and the status of each task in the Run:
Was this page helpful?