Skip to content

How to wait for a specific Job to be processed inside a Controller #1108

Answered by mpscholten
amitaibu asked this question in Q&A
Discussion options

You must be logged in to vote

You could try the following:

  • redirect to a view after scheduling the job
  • use auto refresh to have the view update whenever the job is completed
action CreateBidAction = do
    job <- newRecord @BidJob |> create
    redirectTo ShowBidJobAction { bidJobId = get #id bidJob }

action ShowBidJobAction { bidJobId } = autoRefresh do -- <---- we use auto refresh here
    bidJob <- fetch bidJobId
    bid <- fetch (get #bidId bidJob)
    render ShowBidJobView { .. }

with the view:

render ShowBidJobView { .. } = [hsx|
    {if status == JobStatusSucceeded then renderBid bid else "waiting for bid to process"}
|]
    where
        status = get #status bidJob

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by amitaibu
Comment options

amitaibu
Oct 8, 2021
Maintainer Author

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants