Lucag7
New Member
I have a function that returns a value and uses Wait For on another function, which itself uses an HttpJob (so it also contains a Wait For).
I’m also using another Wait For on a CallSub that calls the first function.
I use this method to generalize the various JSON requests. I have a service module (in this example represented by class C2) with a single function that handles all the requests, adjusting the endpoint each time.
In addition, I have several small functions that format the endpoint to be used (such as the test function), so that these functions can also be called from other classes.
This method works, but I’m not sure whether it’s the correct approach. Could it cause issues, or is it a valid way to handle this sequence of asynchronous calls? Would it be better to use a different approach?
I’m also using another Wait For on a CallSub that calls the first function.
Class C1::
sub s1
wait for(callsub(C2, "test")) complete (resp as String)
log(resp)
end sub
Class C2::
sub test as ResumableSub
wait for (request("/test")) complete (resp1 as String)
return resp
end sub
sub request(endpoint as String) as ResumableSub
Wait For (j) JobDone(j As HttpJob)
return j.GetString
end sub
I use this method to generalize the various JSON requests. I have a service module (in this example represented by class C2) with a single function that handles all the requests, adjusting the endpoint each time.
In addition, I have several small functions that format the endpoint to be used (such as the test function), so that these functions can also be called from other classes.
This method works, but I’m not sure whether it’s the correct approach. Could it cause issues, or is it a valid way to handle this sequence of asynchronous calls? Would it be better to use a different approach?