trying to understand view + model + state management

96
0
07-18-2020 07:07 AM
shaylavi
Esri Contributor

Hi,

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.

Thanks,

Shay.

Shay
0 Kudos
0 Replies