AnsweredAssumed Answered

JS API/Vue watch for data store changes

Question asked by shawnroberts on Feb 5, 2020
Latest reply on Feb 6, 2020 by tcatkins99

What is the best way to have the map watch for changes a data store. (on change do something inside the map). 

 

I have a map as a component which I'd like to bind its definition query to something set in the store. I'm doing it this way as the users interact with a side panel (which IS NOT in the map), so I'm having it update a value in the store via mutations. From there I'd like the map to watch for changes to that value and simply update a layers definition query.

 

I can access the data store perfectly fine from within the map this.$store.state.DefinitionQuery gives me the value I want. But when I try to set the watchUtils watch that value is fires multiple promise and other errors.

 

I'm not committed to this data structure so if anyone has a better way to have the map respond to changes in other components (**not a widget in the map***) I'm open to the ideas as well. 

 

I've attached an example of the map component I've got so far. Right now I'm just trying to make it log on a change, but once I figure out the onChange event I'll bind the pointLayer.definitionQuery to it.

Attachments

Outcomes