Using suspend and resume to wait for async results
async_result_id
. While this is useful if you want to continue the workflow while it is running, sometimes you want to wait for the operation to complete. This is where the suspend_fn
method comes in.
ctx.suspend_fn
method within a Step
function. This will suspend the workflow until a resume event is received.
The standard way to trigger a resume event when a async_result_id
is ready is to use the resume_when_complete
method.
reasoning_sync
) will be called when the workflow is resumed, and the resume data will be passed via the ctx.resume_data
property (in this case, the result from the async_result_id
).
ctx.suspend_fn
with a screen payload before the function returns:
suspend_fn
before the function returns to ensure the loading screen is displayedprops
parameter will be passed to the React component at screenPath
as propsasync_result_id
or task descriptions) that the loading screen can use to provide more detailed feedbackscreenPath
while the workflow is suspended, providing a better user experience during long-running operations.