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:
Any thoughts?
Thanks!!
Alejandro
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);
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.
Hope this helps,
-Undral