Hi
I have an awful web app that is mainly legacy code I wrote many years back, but functions and the users use it all the time
WE're moving stuff around and at the moment the desktops are at a different site to the data so I'm hitting latency issues.
I have this code
<SPAN class="comment token">//return the layer descriptions and © text into arrays - we use this later for the info dialog to generate hyperlinks and © text</SPAN>
dojo<SPAN class="punctuation token">.</SPAN><SPAN class="token function">forEach</SPAN><SPAN class="punctuation token">(</SPAN>dynamicMapServiceLayer<SPAN class="punctuation token">.</SPAN>layerInfos<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">function</SPAN> <SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> requestHandle <SPAN class="operator token">=</SPAN> esri<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>
url<SPAN class="punctuation token">:</SPAN> mapservice2 <SPAN class="operator token">+</SPAN> <SPAN class="string token">"/"</SPAN> <SPAN class="operator token">+</SPAN> layer<SPAN class="punctuation token">.</SPAN>id <SPAN class="operator token">+</SPAN> <SPAN class="string token">"?f=json"</SPAN><SPAN class="punctuation token">,</SPAN>
handleAs<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"json"</SPAN><SPAN class="punctuation token">,</SPAN>
load<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">function</SPAN> <SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
LayerAttach<SPAN class="punctuation token">[</SPAN>layer<SPAN class="punctuation token">.</SPAN>id<SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> data<SPAN class="punctuation token">.</SPAN>hasAttachments<SPAN class="punctuation token">;</SPAN>
console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">debug</SPAN><SPAN class="punctuation token">(</SPAN>dynamicMapServiceLayer<SPAN class="punctuation token">.</SPAN>layerInfos<SPAN class="punctuation token">[</SPAN>layer<SPAN class="punctuation token">.</SPAN>id<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
LayerDescriptions<SPAN class="punctuation token">[</SPAN>layer<SPAN class="punctuation token">.</SPAN>id<SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> data<SPAN class="punctuation token">.</SPAN>description<SPAN class="punctuation token">;</SPAN>
dynamicMapServiceLayer<SPAN class="punctuation token">.</SPAN>layerInfos<SPAN class="punctuation token">[</SPAN>layer<SPAN class="punctuation token">.</SPAN>id<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>copyrightText <SPAN class="operator token">=</SPAN> data<SPAN class="punctuation token">.</SPAN>copyrightText<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN> useProxy<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">true</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Which I have on the Onload event of the main dynamic map It reads extra stuff from the rest data of the service that I use to create hyperlinks (as good old ArcIMS did)
All worked fine until this latency hit. I have a sub-site that on start up takes a feature passed in the URL, finds the extent of that feature, then passes that into a ID task on the main service. The output uses the arrays/data produced in the above routine. With the latency I am getting results of the ID task back before I get all the info from the above code.
I have vague knowledge of defers and the like so surely I should add to each loop above a wait until the data is back until stepping forward, or a wait until everything is back
Any advice welcomed.
In the short term I've given those users who use this sub-site Chrome, which can handle things faster and not get caught up.
Cheers
ACM