You could also add a $watchCollection here on the getLayers().getArray() class. This will also allow you to filter for the right layers (for example to not have preview and background layers).

I think this will simplify the `refreshComp` function a littlbe bit as you get directly all filtered layers.

See https://github.com/geoadmin/mf-geoadmin3/blob/master/src/components/catalogtree/CatalogtreeDirective.js#L139 for an example usage.