<?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 Re: How to convert watchUtils whenFalse whenTrue to reactiveUtils in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-convert-watchutils-whenfalse-whentrue-to/m-p/1179447#M77566</link>
    <description>&lt;P&gt;We are updating the docs for 4.24. This might help in the meantime:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// watchUtils
watchUtils.whenTrue(foo, "some.value", () =&amp;gt; console.log("True"));
watchUtils.whenFalse(foo, "some.value", () =&amp;gt; console.log("False"));

// Equivalent in reactiveUtils
reactiveUtils.when(() =&amp;gt; some.value === true, () =&amp;gt; console.log("True"));
reactiveUtils.when(() =&amp;gt; some.value === false, () =&amp;gt; console.log("False"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Jun 2022 14:35:45 GMT</pubDate>
    <dc:creator>AndyGup</dc:creator>
    <dc:date>2022-06-06T14:35:45Z</dc:date>
    <item>
      <title>How to convert watchUtils whenFalse whenTrue to reactiveUtils</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-convert-watchutils-whenfalse-whentrue-to/m-p/1179415#M77565</link>
      <description>&lt;P&gt;I am using 4.23. How would watchUtils whenFalse and whenTrue be converted to&amp;nbsp;reactiveUtils?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;watchUtils.whenFalse(item.layer, "visible", function (newVal) {
	// do stuff
});

watchUtils.whenTrue(item, "visible", function (newVal) {
	// do stuff
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2022 12:17:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-convert-watchutils-whenfalse-whentrue-to/m-p/1179415#M77565</guid>
      <dc:creator>GregoryBologna</dc:creator>
      <dc:date>2022-06-02T12:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert watchUtils whenFalse whenTrue to reactiveUtils</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-convert-watchutils-whenfalse-whentrue-to/m-p/1179447#M77566</link>
      <description>&lt;P&gt;We are updating the docs for 4.24. This might help in the meantime:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// watchUtils
watchUtils.whenTrue(foo, "some.value", () =&amp;gt; console.log("True"));
watchUtils.whenFalse(foo, "some.value", () =&amp;gt; console.log("False"));

// Equivalent in reactiveUtils
reactiveUtils.when(() =&amp;gt; some.value === true, () =&amp;gt; console.log("True"));
reactiveUtils.when(() =&amp;gt; some.value === false, () =&amp;gt; console.log("False"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 14:35:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-convert-watchutils-whenfalse-whentrue-to/m-p/1179447#M77566</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2022-06-06T14:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert watchUtils whenFalse whenTrue to reactiveUtils</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-convert-watchutils-whenfalse-whentrue-to/m-p/1180169#M77602</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;I'm getting Uncaught ReferenceError ReferenceError: when is not defined&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// watchUtils.whenFalse(item.layer, "visible", function (newVal) {
//  layerListFormat(item);
// });
// watchUtils.whenTrue(item, "visible", function (newVal) {
//  layerListFormat(item); // removed
// });

when(() =&amp;gt; item.layer.visible === true, () =&amp;gt; layerListFormat(item));
when(() =&amp;gt; item.layer.visible === false, () =&amp;gt; layerListFormat(item));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 12:17:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-convert-watchutils-whenfalse-whentrue-to/m-p/1180169#M77602</guid>
      <dc:creator>GregoryBologna</dc:creator>
      <dc:date>2022-06-06T12:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert watchUtils whenFalse whenTrue to reactiveUtils</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-convert-watchutils-whenfalse-whentrue-to/m-p/1180218#M77604</link>
      <description>&lt;P&gt;Oh, whoops, you have to import the module first, here's a working AMD codepen example: &lt;A href="https://codepen.io/andygup/pen/rNJrbzM?editors=1000" target="_blank"&gt;https://codepen.io/andygup/pen/rNJrbzM?editors=1000&lt;/A&gt;.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    /&amp;gt;
    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    &amp;lt;/style&amp;gt;
    &amp;lt;link
      rel="stylesheet"
      href="https://js.arcgis.com/4.23/esri/themes/light/main.css"
    /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.23/"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script&amp;gt;
      require(["esri/Map",
      "esri/views/MapView",
      "esri/core/reactiveUtils"], (Map, MapView, reactiveUtils) =&amp;gt; {
        const map = new Map({
          basemap: "topo-vector"
        });

        const view = new MapView({
          container: "viewDiv",
          map: map,
          zoom: 4,
          center: [15, 65] 
        });
        
        const handle = reactiveUtils.when(
          // getValue function
          () =&amp;gt; view.updating === false,
          // Callback function
          () =&amp;gt; {
            console.log("view update: ", view.updating);
          }
        );        
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With ES modules the import pattern would look like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import { when } from "esri/core/reactiveUtils";

when(() =&amp;gt; item.layer.visible === true, () =&amp;gt; layerListFormat(item));
when(() =&amp;gt; item.layer.visible === false, () =&amp;gt; layerListFormat(item));&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;</description>
      <pubDate>Mon, 06 Jun 2022 14:31:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-convert-watchutils-whenfalse-whentrue-to/m-p/1180218#M77604</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2022-06-06T14:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert watchUtils whenFalse whenTrue to reactiveUtils</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-convert-watchutils-whenfalse-whentrue-to/m-p/1180222#M77605</link>
      <description>&lt;P&gt;I also updated my previous code snippet to hopefully make the pattern more clear.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 14:36:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-convert-watchutils-whenfalse-whentrue-to/m-p/1180222#M77605</guid>
      <dc:creator>AndyGup</dc:creator>
      <dc:date>2022-06-06T14:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert watchUtils whenFalse whenTrue to reactiveUtils</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-convert-watchutils-whenfalse-whentrue-to/m-p/1180377#M77610</link>
      <description>&lt;P&gt;I included the module but missed adding it to the when. It is working.&amp;nbsp;Thank you, Andy.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;reactiveUtils.when(
 () =&amp;gt; item.layer.visible === false,
 () =&amp;gt; {
   layerListFormat(item)
 }
);

reactiveUtils.when(
 () =&amp;gt; item.layer.visible === true,
 () =&amp;gt; {
   layerListFormat(item)
 }
);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 19:19:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-convert-watchutils-whenfalse-whentrue-to/m-p/1180377#M77610</guid>
      <dc:creator>GregoryBologna</dc:creator>
      <dc:date>2022-06-06T19:19:00Z</dc:date>
    </item>
  </channel>
</rss>

