Control map loading 4.x

633
2
05-29-2020 08:29 AM
ThafnySoares
New Contributor III

Hello. I need your help for a problem I'm having with the Javascript API. I have a website that has some tabs, the first of which is where is the map created with the API. The problem is that, eventually, some user goes directly to another tab before the map loading is finished and when he returns to the map tab, the loading was stopped in the middle and the map is incomplete. Is there any way to control the loading of Widgets? I know that there are some methods, however, they don't seem to work very well, for example, I have a Slider that I want to hide the label, however, I need to wait to load the label to do this. So, I use 'updating', but it doesn't always work, follow the code snippet:

view.watch('updating', function(evt){
    query('.esri-slider__label')[0].classList.add("hide");
 });


0 Kudos
2 Replies
JohnGrayson
Esri Regular Contributor

Try using the watchUtils, it might do what you need.

watchUtils.whenFalseOnce(view, 'updating' function(evt){
  query('.esri-slider__label')[0].classList.add("hide");
});‍‍‍
0 Kudos
ChristianBischof
Esri Contributor

I'd suggest John Grayson‌ s approach as well as trying to put some parts of your code inside of a view.when()

view.when(function(){
  //parts of your code
});‍‍‍
0 Kudos