Equivelent event to 'update-end' in 4.4?

770
2
Jump to solution
08-21-2017 07:07 PM
MatthewPilz
New Contributor II

Hi. In 3.x there existed an event handler 'update-end' that would be called when the map tiles in the view had finished loading. In 4.x this does not seem to be an option, and the 'then' promise is called as soon as the view initializes but before the data has actually completed loading. Is there an alternative event to facilitate code execution only after the map layer imagery has actually loaded?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Matthew,

   Sure there is it is just a property on the layer view called updating:

view.whenLayerView(lyr).then(function(lyrView){
  lyrView.watch("updating", function(val){
    if(!val){  // wait for the layer view to finish updating
      //Now do something after the layer is done drawing
    }
  });
});

or you could use WatchUtils whenFalse:

view.whenLayerView(lyr).then(function(lyrView){
  watchUtils.whenFalse(lyrView, "updating", function(val){
    //Now do something after the layer is done drawing
  });
});‍‍‍‍‍‍‍

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Matthew,

   Sure there is it is just a property on the layer view called updating:

view.whenLayerView(lyr).then(function(lyrView){
  lyrView.watch("updating", function(val){
    if(!val){  // wait for the layer view to finish updating
      //Now do something after the layer is done drawing
    }
  });
});

or you could use WatchUtils whenFalse:

view.whenLayerView(lyr).then(function(lyrView){
  watchUtils.whenFalse(lyrView, "updating", function(val){
    //Now do something after the layer is done drawing
  });
});‍‍‍‍‍‍‍
KenBuja
MVP Esteemed Contributor

Rene Rubalcava‌ has created a nice blog post about when things are ready in 4.x: Quick Tip: ArcGIS API 4 for JS - When stuff is ready? - odoenet 

0 Kudos