function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Greg CooganGreg Coogan 

Apex Equivalent of Javascript Promises

I am integrating with an external endpoint. The first step is to retrieve a token. When I first developed my solution, I did it all in Apex. However, I ran into an issue where my code would proceed to do a POST (my second step) before the token was recieved. As a result, I switched to using Javascript and its "Promises" on the Visualforce page that is run via custom button. In Apex, how would you replicate the Javascript Promises functionality that waits for a token to be received?
Raj VakatiRaj Vakati
we dnt have any such in apex ( Becasue we dnt have thread and runnable interfacess)

what i coud say is defind the apex code that call from the response by using apex


 
Greg CooganGreg Coogan
I realize we don't have Promises in Apex. I'm asking how would you code a similar solution in Apex. I was thinking something of a While loop, but wanted to hear from other developers that may have done it in the past.

Also, I could not exactly tell what you mean by "what i coud say is defind the apex code that call from the response by using apex."