Open fschmenger opened 3 months ago
Hi guys, here is where to take a closer look:
Unfortunately I will have to focus on other projects again in the upcoming months, so take your time for review. If we're happy with the overall solution, feel free to work on it. It should`t be too much from here on.
Cheers Felix
This is my take on how we could possibly fix the layer-property-reactivity issue mentioned in #365. To keep changes minimal I decided to wrap up OL layers and OL layer collections by proxy objects. The proxy objects behave mostly transparent and forward invocations to the underlying layer / collection objects, so they can be basically used as a drop-in. Apparently, use them only for Vue components when reactivity is required.
Using LayerProxy around an OL layer:
layerProxy = new LayerProxy(myLayer, ['legend', 'legendOptions'])
layerProxy.destroy()
layerProxy.getLayer()
Internally, the layer proxy traps thegetProperties()
andget()
methods to return a self managed object of key value pairs, which is synced via OL observables.Similarly, using LayerProxyCollection around an OL Collection:
collectionProxy = new LayerCollectionProxy(myLayerCollection, ['lid', 'displayInLayerList', 'isBaseLayer']);
collectionProxy .destroy()
collectionProxy.getCollection()
Internally, the collection proxy traps theforEach()
,item()
andgetArray()
methods to return LayerProxy objects.So far, this only the proof of concept. Here is the list of (open) tasks: 1) Implement layer proxy object (done) 2) Implement layer collection proxy (done) 3) Use layer proxy and proxy collection in various vue components. A quick search yielded: