I'm working on customizing a widget and I need access to all of the layers and tables in the map to clear selections. I was imitating other parts of Web AppBuilder and using LayerInfos. I had no problem doing this with a custom class that was probably loaded later in the application loading process. However, this time around I am having some issues. Here is the code I am running:
var layerInfosObj = LayerInfos.getInstanceSync();
var layerObjects = [];
layerInfosObj.getLayerInfoArray().forEach(function (layerInfo) {
layerObjects.push(layerInfo.layerObject);
});
layerInfosObj.getTableInfoArray().forEach(function (tableInfo) {
layerObjects.push(tableInfo.layerObject);
});
I added this code to an event handler that subscribes to app/mapLoaded. The layer objects I get from the layers are all fully built out. The ones from the tables are somewhat empty objects. If I run the same code after the app is fully loaded, the layer objects for the tables are complete. I need the layer Objects for the tables to have the clearSelection method and they don't on app/mapLoaded.
Is there another topic I could subscribe to that occurs later? I have no idea where to find documentation on these subscription topics. I searched for app/mapLoaded elsewhere in the code and I could not find where it is published. Therefore, I don't know how this works.