AnsweredAssumed Answered

trying to understand view + model + state management

Question asked by slaviesriaustralia-com-au-esridist Employee on Jul 18, 2020



I'm starting to learn version 4 of the API and trying to develop a custom widget that runs a geoprocessing tool.


I've tried to follow a sample but it's quite overwhelming and hard to follow the logic.


I just want to implement a button click that will send a request to a service (promise), then respond accordingly. Basically, I would like to show a loader while the promise is running and then "turn off" the loader when I have the result.


So I have a floating panel with a button, I have an async function to send a request using the geoprocessing example from the API, but I can't figure how to implement the state management properly.


Based on the example I found, I divided my code into 2 files - 1 is for the View/UI, 2nd is the ViewModel.

I've tried to use the get property in the ViewModel to be used as a status, which can be read from the View... But I couldn't figure out how to change and track that property and everything got really messy at that point. 


Anyone knows of a simple example for this I can use?

ViewModel + status property to "watch" for changes,  then a View that reads the status property.