arcgis-js-api

view.popup.watch is not a function -upgrading from arcgis 4.26 to 4.27


I have a line of code that was working fine in ArcGIS javascript api 4.26. Updating ArcGIS javascript api from 4.26 to 4.27, I am receiving this error:

view.popup.watch is not a function

Here is the failing line:

view.popup.watch("selectedFeature", (graphic) => {

Looks like esri deprecated this. Does anyone know the correct replacement for performing this watch now on 4.27?


Solution

  • You can use reactiveUtils (ArcGIS API - reactiveUtils), it seems that the library is favoring this.

    reactiveUtils.watch(
      () => view.popup.selectedFeature,
      (graphic) => {
        if (graphic) {
            // ...
        }
      }
    );