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.jobs/yourjob.ts
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
TheuseEventRunStatuses
hook will give you the statuses and overview data of the first run that is triggered by an event.
How do I get an event id?
How do I get an event id?
When you use
sendEvent it will
return basic details about the event, including the
id
of the event. You can
then pass this to your frontend to use in the useEventRunDetails
hook.useRunStatuses
TheuseRunStatuses
hook will give you the statuses and overview data of a specific Run.
How do I get a Run id?
How do I get a Run id?
You can call client.getRuns() with a Job id to get a
list of the most recent Runs for that Job. You can then pass that run id to your frontend to use
in the hook.