It's all about the answers!

Ask a question

Asynchronous http calls in a script based calculated value?

Noel Gimeno (1521417) | asked Mar 10 '16, 8:48 a.m.
edited Mar 10 '16, 8:49 a.m.
Hello good afternoon!

Is it possible to do http asynchronous calls to a OSLC service in RTC within a calculated value script?

Not by using the "" in a value set, but for example with the http client: jazz.client.xhrGet(request).

RTC Version 5.0.2

Thank you!

Donald Nong commented Mar 10 '16, 11:54 p.m.

I see in the other post that you can do synchronous request already. Why asynchronous then? Your code logic in the calculated value script has to be in sequence, and an asynchronous request in the middle does not make sense.

Noel Gimeno commented Mar 18 '16, 8:40 a.m. | edited Mar 18 '16, 8:42 a.m.

Hello Donald, thanks for your comment!

In all server extensions involving java script I use asynchronous calls. This allows to continue the flow of the script, as you comment, an receive the results later when they are ready, without the script blocked, waiting for the return of the HTTP call.

If the request takes long in responding, with a synchronous call the screen freezes until the return is received.

I wonder if I can use "dojo.hitch" mechanism, like in the server java script extensions, so that the value of the attribute is filled once the service returned the value, but without blocking the user interface in a meantime.

sam detweiler commented Mar 18 '16, 9:35 a.m.

the problem is what do you do about the value you didn't return from the main script invocation?  that design EXPECTS a value immediately.. and it blocks the UI til it GETS the value..

so you cannot make it 'not return' but be asynch at the same time.

now if the call to the script said 'post the value here when you get it'
and async secondary scrpt might work..  but it doesn't it is looking for the script return value.

Be the first one to answer this question!

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.