refresh event on Feature Layer not being triggered

156
2
12-10-2021 10:23 AM
AlejandroMari1
Occasional Contributor

Hello! I'd like to perform some actions when a layer is refreshed. I have a Feature Layer for which I'm explicitly setting the refresh interval and then trying to listen to the "refresh" event (as defined on the documentation: https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#events-s...)

layer.refreshInterval = 1; // Refresh every 1 minute
layer.on("refresh", (event) => {
    console.log("layer refreshed!");
});

The problem is that the refresh event doesn't trigger. I can confirm that the layer is actually refreshing, as I can see the requests going out every minute and the layer updating on the map.

What's also interesting is that the "refresh" event is not defined in the TypeScript definitions on arcgis-js-api.d.ts. Only the other four:

on(name: "edits", eventHandler: FeatureLayerEditsEventHandler): IHandle;
on(name: "layerview-create", eventHandler: FeatureLayerLayerviewCreateEventHandler): IHandle;
on(name: "layerview-create-error", eventHandler: FeatureLayerLayerviewCreateErrorEventHandler): IHandle;
on(name: "layerview-destroy", eventHandler: FeatureLayerLayerviewDestroyEventHandler): IHandle;

 The event is supposed to have been there since version 4.0 according to the docs.

Environment:

  • ArcGIS JS API 4.20
  • Experience Builder 1.5
  • ArcGIS Enterprise 10.9.0

Any thoughts?

Thanks!!

Alejandro

0 Kudos
2 Replies
AlejandroMari1
Occasional Contributor

I just noticed that if I manually force the refresh of the layer calling the .refresh() method, the event does fire. It seems not to fire when I use the .refreshInterval property.

Sample:

 

setInterval(() => {
    layer.refresh()
}, 60000);

 

0 Kudos
UndralBatsukh
Esri Regular Contributor

Hi there, 

If you go to the refresh event description, you will see that refresh event was added at 4.21. See the since tag in the screenshot.

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#event-re...

Screen Shot 2021-12-10 at 3.39.48 PM.png

 

Hope this helps,

-Undral

0 Kudos