<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic reactiveUtils ESM import problem in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/reactiveutils-esm-import-problem/m-p/1563268#M86152</link>
    <description>&lt;P&gt;Hello! I have encountered a problem using reactiveUtils | API Reference | ArcGIS Maps SDK for JavaScript 4.31 | Esri Developer. The setup i have is a small test server which consumes a webcomponent. The webcomponent uses the &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core NPM package. The problem is that i can't get the reactiveUtil to work as expected. Im trying to use the watch function in the reactiveUtils module. It initially runs the provided getValue function once but not later when the value is updated.&lt;/P&gt;&lt;P&gt;I have created a test example where i provide a reactiveUtils instance to the webcomponent from the test server, this reactiveUtils being imported using the AMD method. This instance of reactiveUtils works as expected.&lt;/P&gt;&lt;P&gt;This is the ESM import&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import * as reactiveUtils from "@arcgis/core/core/reactiveUtils.js"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this is the test erver with the AMD import&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require(["esri/core/reactiveUtils"], (reactiveUtils) =&amp;gt; {
    const myWebComponent = new MyWebComponent();
    myWebComponent.ru = reactiveUtils;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I the use both of these instances in the webcomponent as follows&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.ru.watch(()=&amp;gt; {
   console.log("watching AMD", this.selectionLayer.graphics.length)
   return this.selectionLayer.graphics.length
}, () =&amp;gt; console.log('Graphics changed! AMD'));

reactiveUtils.watch(()=&amp;gt; {
   console.log("watching ESM", this.selectionLayer.graphics.length)
   return this.selectionLayer.graphics.length
}, () =&amp;gt; console.log('Graphics changed! ESM'));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then in the browser we expect the console to log initally both "watching AMD" and "watching ESM" which it does&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="majae_0-1732805403726.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/120540iAF8F8123D6BFC7C8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="majae_0-1732805403726.png" alt="majae_0-1732805403726.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then when we add a graphic to the 'selectionLayer' we expect the console to log "watching AMD", 'Graphics changed! AMD',"watching ESM" and 'Graphics changed! ESM' however only the reactiveUtils from the ESM import runs&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":loudly_crying_face:"&gt;😭&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="majae_1-1732805445540.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/120541iF5442D48E34EDB09/image-size/medium?v=v2&amp;amp;px=400" role="button" title="majae_1-1732805445540.png" alt="majae_1-1732805445540.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does anyone have any idea what the issue may be? As i wrote it doesn't have any issue finding and running the file at &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core/core/reactiveUtils.js but the functionality does not work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Have tried with &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core versions 4.27.6 and 4.31.6&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance, Maja&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Nov 2024 14:52:10 GMT</pubDate>
    <dc:creator>majae</dc:creator>
    <dc:date>2024-11-28T14:52:10Z</dc:date>
    <item>
      <title>reactiveUtils ESM import problem</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/reactiveutils-esm-import-problem/m-p/1563268#M86152</link>
      <description>&lt;P&gt;Hello! I have encountered a problem using reactiveUtils | API Reference | ArcGIS Maps SDK for JavaScript 4.31 | Esri Developer. The setup i have is a small test server which consumes a webcomponent. The webcomponent uses the &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core NPM package. The problem is that i can't get the reactiveUtil to work as expected. Im trying to use the watch function in the reactiveUtils module. It initially runs the provided getValue function once but not later when the value is updated.&lt;/P&gt;&lt;P&gt;I have created a test example where i provide a reactiveUtils instance to the webcomponent from the test server, this reactiveUtils being imported using the AMD method. This instance of reactiveUtils works as expected.&lt;/P&gt;&lt;P&gt;This is the ESM import&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import * as reactiveUtils from "@arcgis/core/core/reactiveUtils.js"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this is the test erver with the AMD import&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require(["esri/core/reactiveUtils"], (reactiveUtils) =&amp;gt; {
    const myWebComponent = new MyWebComponent();
    myWebComponent.ru = reactiveUtils;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I the use both of these instances in the webcomponent as follows&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.ru.watch(()=&amp;gt; {
   console.log("watching AMD", this.selectionLayer.graphics.length)
   return this.selectionLayer.graphics.length
}, () =&amp;gt; console.log('Graphics changed! AMD'));

reactiveUtils.watch(()=&amp;gt; {
   console.log("watching ESM", this.selectionLayer.graphics.length)
   return this.selectionLayer.graphics.length
}, () =&amp;gt; console.log('Graphics changed! ESM'));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then in the browser we expect the console to log initally both "watching AMD" and "watching ESM" which it does&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="majae_0-1732805403726.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/120540iAF8F8123D6BFC7C8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="majae_0-1732805403726.png" alt="majae_0-1732805403726.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then when we add a graphic to the 'selectionLayer' we expect the console to log "watching AMD", 'Graphics changed! AMD',"watching ESM" and 'Graphics changed! ESM' however only the reactiveUtils from the ESM import runs&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":loudly_crying_face:"&gt;😭&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="majae_1-1732805445540.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/120541iF5442D48E34EDB09/image-size/medium?v=v2&amp;amp;px=400" role="button" title="majae_1-1732805445540.png" alt="majae_1-1732805445540.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does anyone have any idea what the issue may be? As i wrote it doesn't have any issue finding and running the file at &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core/core/reactiveUtils.js but the functionality does not work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Have tried with &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core versions 4.27.6 and 4.31.6&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance, Maja&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2024 14:52:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/reactiveutils-esm-import-problem/m-p/1563268#M86152</guid>
      <dc:creator>majae</dc:creator>
      <dc:date>2024-11-28T14:52:10Z</dc:date>
    </item>
  </channel>
</rss>

