Does anyone have an example of how to detect when a layer changes visibility? I'm trying to use the reactiveUtils but no luck.
below is what I think should work and is in one of the reactiveUtils Samples but doesn't seem to work even in the sample. (it never triggers the callback function when i turn on and off layers).
// Use reactiveUtils to check when a Collection has changed
reactiveUtils.watch(
() => [view.map.allLayers.forEach((layer) => layer.visible)],
() => {
console.log("layer visibiblity changed")
let layerNames = "";
renderVisibleLayers(layerNames);
}
);
Or perhaps there is a better way to set up an event listener on all my layers for visibility?
Thanks in advance.
Jason.