<?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 Easier way to track (and test) changes to SnappingOptions? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/easier-way-to-track-and-test-changes-to/m-p/1407762#M84270</link>
    <description>&lt;P&gt;I'm trying to persist the settings as a User changes things like SnappingOptions:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-04-08 at 3.37.16 PM.png" style="width: 200px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/100529i323C8F6D4D163781/image-size/small?v=v2&amp;amp;px=200" role="button" title="Screenshot 2024-04-08 at 3.37.16 PM.png" alt="Screenshot 2024-04-08 at 3.37.16 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here's the gist of how I've attempted to do this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const optionsObject = new SnappingOptions(initialSettings);
const listenForFeatureEnabled = optionsObject.watch('featureEnabled', () =&amp;gt; {
    persistSnappingSettings(optionsObject); 
});
const listenForSelfEnabled = optionsObject.watch('selfEnabled', () =&amp;gt; {
    persistSnappingSettings(optionsObject); 
});
// ... more code ...
optionsObject.addHandles([ 
     listenForFeatureEnabled, 
     listenForSelfEnabled,
     // ... more listeners ...
])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Things start to get ugly with the FeatureSnappingLayerSource objects.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const listenForFeatureSourceChanges = optionsObject.featureSources.on('change', (event) =&amp;gt; {
    // This is helpful when a new layer is added to the MapView
    persistSnappingSettings(optionsObject);

    // &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/69004"&gt;@ts&lt;/a&gt;-ignore
    event.target.forEach((fs: FeatureSnappingLayerSource) =&amp;gt; {
      if (!fs.get(isBeingTrackedIndicator)) {
        fs.set(isBeingTrackedIndicator, true);
        reactiveUtils.watch(() =&amp;gt; fs.enabled, () =&amp;gt; {
          persistSnappingSettings(optionsObject);
        });
      }
    });
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a 3 part question:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Is there an easier way to watch these properties, or is this the "Esri way"?&lt;/LI&gt;&lt;LI&gt;Could ignoring the handles returned on line 9 cause issues? Should I be doing an adding those handles to the optionsObject?&lt;/LI&gt;&lt;LI&gt;How can I write unit tests for this? I can verify the optionsObject &lt;FONT face="courier new,courier"&gt;hasHandles()&lt;/FONT&gt;, but that's not too useful. Can I get ahold of those handles somehow and execute them, or is there some other approach that would let me test that functionality?&lt;/LI&gt;&lt;/OL&gt;</description>
    <pubDate>Tue, 09 Apr 2024 22:03:23 GMT</pubDate>
    <dc:creator>ToddRunstein</dc:creator>
    <dc:date>2024-04-09T22:03:23Z</dc:date>
    <item>
      <title>Easier way to track (and test) changes to SnappingOptions?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/easier-way-to-track-and-test-changes-to/m-p/1407762#M84270</link>
      <description>&lt;P&gt;I'm trying to persist the settings as a User changes things like SnappingOptions:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-04-08 at 3.37.16 PM.png" style="width: 200px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/100529i323C8F6D4D163781/image-size/small?v=v2&amp;amp;px=200" role="button" title="Screenshot 2024-04-08 at 3.37.16 PM.png" alt="Screenshot 2024-04-08 at 3.37.16 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here's the gist of how I've attempted to do this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const optionsObject = new SnappingOptions(initialSettings);
const listenForFeatureEnabled = optionsObject.watch('featureEnabled', () =&amp;gt; {
    persistSnappingSettings(optionsObject); 
});
const listenForSelfEnabled = optionsObject.watch('selfEnabled', () =&amp;gt; {
    persistSnappingSettings(optionsObject); 
});
// ... more code ...
optionsObject.addHandles([ 
     listenForFeatureEnabled, 
     listenForSelfEnabled,
     // ... more listeners ...
])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Things start to get ugly with the FeatureSnappingLayerSource objects.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const listenForFeatureSourceChanges = optionsObject.featureSources.on('change', (event) =&amp;gt; {
    // This is helpful when a new layer is added to the MapView
    persistSnappingSettings(optionsObject);

    // &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/69004"&gt;@ts&lt;/a&gt;-ignore
    event.target.forEach((fs: FeatureSnappingLayerSource) =&amp;gt; {
      if (!fs.get(isBeingTrackedIndicator)) {
        fs.set(isBeingTrackedIndicator, true);
        reactiveUtils.watch(() =&amp;gt; fs.enabled, () =&amp;gt; {
          persistSnappingSettings(optionsObject);
        });
      }
    });
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a 3 part question:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Is there an easier way to watch these properties, or is this the "Esri way"?&lt;/LI&gt;&lt;LI&gt;Could ignoring the handles returned on line 9 cause issues? Should I be doing an adding those handles to the optionsObject?&lt;/LI&gt;&lt;LI&gt;How can I write unit tests for this? I can verify the optionsObject &lt;FONT face="courier new,courier"&gt;hasHandles()&lt;/FONT&gt;, but that's not too useful. Can I get ahold of those handles somehow and execute them, or is there some other approach that would let me test that functionality?&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Tue, 09 Apr 2024 22:03:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/easier-way-to-track-and-test-changes-to/m-p/1407762#M84270</guid>
      <dc:creator>ToddRunstein</dc:creator>
      <dc:date>2024-04-09T22:03:23Z</dc:date>
    </item>
  </channel>
</rss>

