{"id":1810112,"date":"2023-02-22T17:00:50","date_gmt":"2023-02-23T01:00:50","guid":{"rendered":"https:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=1810112"},"modified":"2024-04-12T03:10:54","modified_gmt":"2024-04-12T10:10:54","slug":"reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript","status":"publish","type":"blog","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript","title":{"rendered":"Why you should be using reactiveUtils instead of watchUtils"},"author":293472,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_acf_changed":false,"_searchwp_excluded":""},"categories":[738191],"tags":[768932,27491],"industry":[],"product":[761642,36831],"class_list":["post-1810112","blog","type-blog","status-publish","format-standard","hentry","category-developers","tag-4-26","tag-jsapi4","product-platform","product-js-api-arcgis"],"acf":{"authors":[{"ID":331562,"user_firstname":"Hugo","user_lastname":"Campos","nickname":"hcampos","user_nicename":"hcampos","display_name":"Hugo Campos","user_email":"hcampos@esri.com","user_url":"","user_registered":"2023-02-10 08:56:57","user_description":"Hugo is a Software Engineer from Portugal working in Zurich on the ArcGIS API for JavaScript, with a focus on widgets and 3D interactive tools. He is passionate about the web and is always up to date with the ever-changing world of JavaScript. When he is not programming, Hugo likes to spend time hiking in the mountains, taking landscape photos or cycling. He would love to hear from you so feel free to reach out with all your questions about widgets, JavaScript\/Typescript, or other frontend technologies!","user_avatar":"<img data-del=\"avatar\" src='https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/02\/profile-img-213x200.jpg' class='avatar pp-user-avatar avatar-96 photo ' height='96' width='96'\/>"},{"ID":3801,"user_firstname":"Andy","user_lastname":"Gup","nickname":"andygup","user_nicename":"andygup","display_name":"Andy Gup","user_email":"agup@esri.com","user_url":"http:\/\/www.andygup.net","user_registered":"2018-03-02 00:15:25","user_description":"I spend a ton of time outdoors and when not on a mountain somewhere I'm a Sr. Product Engineer for the ArcGIS Maps SDK for JavaScript. I work on ES modules, 3rd party JavaScript frameworks, and other cool mapping-related goodies.","user_avatar":"<img data-del=\"avatar\" src='https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/07\/andy_gup_thumb4-1.png' class='avatar pp-user-avatar avatar-96 photo ' height='96' width='96'\/>"},{"ID":293472,"user_firstname":"Lauren","user_lastname":"Boyd","nickname":"Lauren Boyd","user_nicename":"lauren-boyd","display_name":"Lauren Boyd","user_email":"LBoyd@esri.com","user_url":"https:\/\/github.com\/lboyd93","user_registered":"2021-11-20 01:01:42","user_description":"Lauren is a Senior Product Engineer on the ArcGIS Maps SDK for JavaScript team in Redlands, CA with her work focusing primarily on popups and security. She has worked at Esri for over 8 years and enjoys helping\/supporting geo-developers utilize the JavaScript Maps SDK into their awesome applications.","user_avatar":"<img data-del=\"avatar\" src='https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/12\/LaurenBoydBlogCropped-213x200.png' class='avatar pp-user-avatar avatar-96 photo ' height='96' width='96'\/>"}],"short_description":"Information on the benefits of using reactiveUtils over watchUtils with the ArcGIS Maps SDK for JavaScript.","flexible_content":[{"acf_fc_layout":"content","content":"<p>Observing for changes is one of the most important aspects of managing application life-cycle. At version 4.23 (March 2022) we introduced a new module to the ArcGIS Maps SDK for JavaScript (JavaScript Maps SDK) called <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-core-reactiveUtils.html\">reactiveUtils<\/a> to provide developers with significantly improved watch tooling. This module contains utilities for observing changes in the state of properties using <a href=\"https:\/\/dev.to\/ryansolid\/a-hands-on-introduction-to-fine-grained-reactivity-3ndf\">reactivity<\/a>, which is based on the concepts of reactive programming. It is meant to replace the deprecated watchUtils module, and its utilities have a wider range of capabilities, such as the ability to watch almost anything, being TypeScript safe and more scalable. In this blog post, we will highlight some of the differences between the two modules and explain why you should migrate your app to these new utilities.<\/p>\n<p>&nbsp;<\/p>\n<h2>From watchUtils to reactiveUtils<\/h2>\n"},{"acf_fc_layout":"sidebar","content":"<p style=\"text-align: center;\">The watchUtils module has been removed at version 4.28.<\/p>\n","image_reference":false,"layout":"standard","image_reference_figure":"","snippet":"","spotlight_name":"","section_title":"","position":"Center","spotlight_image":false},{"acf_fc_layout":"content","content":"<p>When we originally introduced <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-core-Accessor.html\">Accessor<\/a> and reactive properties, we didn\u2019t have support for reactivity. Accessor is the parent class for many of the SDKs classes. Developers had to manually specify dependencies between properties. For example, you could use the watchUtils module as follows using a string to set the property name:<\/p>\n<pre><code style=\"padding: 0.5em; color: #333; background: #f8f8f8;\"><span style=\"color: #998; font-style: italic;\">\/\/ Call the callback when view.stationary changes.<\/span>\r\nwatchUtils.watch(view, <span style=\"color: #d14;\">'stationary'<\/span>, (stationary) =&gt; {\r\n  <span style=\"color: #998; font-style: italic;\">\/\/ Do something with the new value<\/span>\r\n});\r\n<span style=\"color: #998; font-style: italic;\">\/\/ Call the callback when view.interacting or view.navigating change.<\/span>\r\nwatchUtils.watch(view, [<span style=\"color: #d14;\">'interacting'<\/span>, <span style=\"color: #d14;\">'navigating'<\/span>], () =&gt; {\r\n  <span style=\"color: #998; font-style: italic;\">\/\/ Do something<\/span>\r\n});\r\n<span style=\"color: #998; font-style: italic;\">\/\/ Call the callback when the view becomes stationary.<\/span>\r\nwatchUtils.when(view, <span style=\"color: #d14;\">'stationary'<\/span>, () =&gt; {\r\n  <span style=\"color: #998; font-style: italic;\">\/\/ Do something when the view becomes stationary.<\/span>\r\n});\r\n<span style=\"color: #998; font-style: italic;\">\/\/ Call the callback when the state is equal to \u201cready\u201d<\/span>\r\nwatchUtils.whenEqualOnce(widget, <span style=\"color: #d14;\">'state'<\/span>, <span style=\"color: #d14;\">'ready'<\/span>, () =&gt; {\r\n  <span style=\"color: #998; font-style: italic;\">\/\/ Do something when the state is \u201cready\u201d.<\/span>\r\n});\r\n<\/code><\/pre>\n<p>The watchUtils pattern is always similar: provide the object to be tracked, one or several of its properties as strings, and a callback which is called when a property changes or when a condition is met.<\/p>\n<p>Let\u2019s see how to implement the same examples with the new reactiveUtils:<\/p>\n<pre><code style=\"padding: 0.5em; color: #333; background: #f8f8f8;\"><span style=\"color: #998; font-style: italic;\">\/\/ Call the callback when a property changes.<\/span>\r\nreactiveUtils.watch(\r\n  () =&gt; view.stationary, \r\n  (stationary) =&gt; {\r\n  <span style=\"color: #998; font-style: italic;\">\/\/ Do something with the new value<\/span>\r\n});\r\n<span style=\"color: #998; font-style: italic;\">\/\/ Call the callback when view.interacting or view.navigating change.<\/span>\r\nreactiveUtils.watch(\r\n  () =&gt; [view.interacting, view.navigating], \r\n  ([interacting, navigating]) =&gt; {\r\n  <span style=\"color: #998; font-style: italic;\">\/\/ Do something<\/span>\r\n});\r\n<span style=\"color: #998; font-style: italic;\">\/\/ Call the callback when the view becomes stationary.<\/span>\r\nreactiveUtils.when(\r\n  () =&gt; view.stationary, \r\n  () =&gt; {\r\n    <span style=\"color: #998; font-style: italic;\">\/\/ Do something when the view becomes stationary.<\/span>\r\n});\r\n<span style=\"color: #998; font-style: italic;\">\/\/ Call the callback when the state is equal to \u201cready\u201d<\/span>\r\nreactiveUtils.when(\r\n  () =&gt; widget.state === <span style=\"color: #d14;\">'ready'<\/span>, \r\n  () =&gt; {\r\n    <span style=\"color: #998; font-style: italic;\">\/\/ Do something when the state is \u201cready\u201d one time.<\/span>\r\n}, \r\n{ once: <span style=\"color: #333; font-weight: 500;\">true<\/span> });\r\n<\/code><\/pre>\n<p>As you can see, the pattern is slightly different, you don\u2019t need to specify which properties are to be observed. Instead, we provide a reactive expression as the first argument to the watch() and when() functions. An expression is code that resolves to a value. This expression is evaluated and, when its result changes (in the case of watch) or becomes truthy (in the case of when), the callback is called.<\/p>\n<p>One way to think about it is to compare it to Excel spreadsheet. In an Excel spreadsheet, you can create formulas that reference other cells (properties) and compute a result. The formula is like a reactive expression, and the cell containing the formula (where the result is displayed) is like a reactiveUtils callback, which receives the result of evaluating the reactive expression.<\/p>\n<pre><code style=\"padding: 0.5em; color: #333; background: #f8f8f8;\"><span style=\"color: #998; font-style: italic;\">\/\/ Evaluate the reactive expression and, when it changes, call the callback with the result.<\/span>\r\nreactiveUtils.watch(\r\n  reactiveExpression, \r\n  (result) =&gt; {\r\n    \/\/ Do something\r\n  }, options);\r\n<\/code><\/pre>\n<p>As we can see in the previous examples, we can also provide some options to control how a watch behaves, such as the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-core-reactiveUtils.html#ReactiveWatchOptions\">ReactiveWatchOptions<\/a> properties <em>once<\/em>, <em>sync<\/em>, <em>initial<\/em> and <em>equals<\/em>:<\/p>\n<pre><code style=\"padding: 0.5em; color: #333; background: #f8f8f8;\"><span style=\"color: #998; font-style: italic;\">\/\/ Run synchronously, in the same tick, as soon as a property changes.<\/span>\r\nreactiveUtils.watch(\r\n  () =&gt; {}, \r\n  callback, \r\n  { sync: <span style=\"color: #333; font-weight: 500;\">true<\/span> });\r\n\r\n<span style=\"color: #998; font-style: italic;\">\/\/ Run right away with the initial result of the expression.<\/span>\r\nreactiveUtils.watch(\r\n  () =&gt; {}, \r\n  callback, \r\n  { initial: <span style=\"color: #333; font-weight: 500;\">true<\/span> });\r\n\r\n<span style=\"color: #998; font-style: italic;\">\/\/ Provide a custom equality function. The callback will only be called if<\/span>\r\n<span style=\"color: #998; font-style: italic;\">\/\/ two consecutive results are not the same.<\/span>\r\nreactiveUtils.watch(\r\n  () =&gt; {}, \r\n  callback, \r\n  { equals: (a, b) =&gt; a === b});\r\n<\/code><\/pre>\n"},{"acf_fc_layout":"content","content":"<h2>Other features and benefits<\/h2>\n<p>So far, we\u2019ve only seen how we can replicate things which was also possible with watchUtils. However, reactiveUtils are significantly more advanced. We\u2019ll now look at some of the benefits of using the reactiveUtils.<\/p>\n<h3>You can observe (almost) anything<\/h3>\n<p>Since we can pass any expression to the reactiveUtils, we can observe almost anything. For example, let\u2019s observe changes in a <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-core-Collection.html\">Collection<\/a>.<\/p>\n<pre><code style=\"padding: 0.5em; color: #333; background: #f8f8f8;\">reactiveUtils.watch(\r\n  () =&gt; view.map.layers.filter((layer) =&gt; layer.visible).toArray(),\r\n  (visibleLayers) =&gt; {\r\n    \/\/ Do something with the visibleLayers Collection\r\n  }\r\n);\r\n<\/code><\/pre>\n<p>With this watch, the callback will be called anytime the list of visible layers changes. If a layer is added\/removed\/moved, the callback will be called with an updated list. And if any of the layers in the Collection has their visible property changed, the callback will also be called with an updated list of layers.<\/p>\n<p>Note, currently reactiveUtils doesn\u2019t support observing native arrays, <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Map\">Map<\/a> or <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Set\">Set<\/a>.<\/p>\n<h3>Automatic dependencies<\/h3>\n<p>One of the key benefits of using <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-core-reactiveUtils.html\">reactiveUtils<\/a> is that it automatically tracks and manages dependencies between different Accessor properties and your application. With reactiveUtils, you never reference properties by name like you do with watchUtils. Instead, <strong>any property accessed in a reactive expression is automatically tracked and depended on by the watch<\/strong>. This means that you don&#8217;t have to worry about forgetting to include a dependency in your watch, because reactiveUtils will automatically track all dependencies for you.<\/p>\n<p>Moreover, reactiveUtils automatically manages dependencies in a dynamic and efficient way. If you modify a reactive expression and it no longer depends on a certain property, that property will no longer be observed, which can save computation time and improve performance. For example, consider the following code:<\/p>\n<pre><code style=\"padding: 0.5em; color: #333; background: #f8f8f8;\">reactiveUtils.watch(\r\n  () =&gt; view.stationary ? view.map.layers.toArray() : [],\r\n  (layers) =&gt; {\r\n    \/\/ Do something with the layers\r\n  }\r\n);\r\n<\/code><\/pre>\n<p>In this case, the reactive expression contains a conditional operator that depends on the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-views-MapView.html#stationary\">view.stationary<\/a> Boolean property. This means that the watch will always depend on view.stationary, because the conditional is always accessed in the reactive expression. However, the watch will only observe the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-Map.html#layers\">view.map.layers<\/a> Collection while view.stationary evaluates as true.<\/p>\n<h3>Much better refactoring and TypeScript support<\/h3>\n<p>Having properties accessed directly in an expression also means that code refactoring tools, such as Typescript, will work out-of-the-box. If you use Typescript to refactor an Accessor property in your code, the change will be automatically propagated throughout your codebase and all reactive watches will continue to work correctly.<\/p>\n<p>In contrast, when using watchUtils, you need to manually update every single watch that specifies a dependency on a property that you are refactoring. This can be error-prone and time-consuming, and it&#8217;s easy to forget to update some watches.<\/p>\n<p>Furthermore, reactiveUtils allows Typescript to automatically infer the types of properties in your reactive expression. This means that you don&#8217;t have to manually specify the types of the callback arguments, which can save time, reduce or eliminate errors as well as make your code easier to read. For example, consider the following code:<\/p>\n<pre><code style=\"padding: 0.5em; color: #333; background: #f8f8f8;\"><span style=\"color: #998; font-style: italic;\">\/\/ Typescript doesn\u2019t know that fullName is a string, so we need to specify it.<\/span>\r\n<span style=\"color: #998; font-style: italic;\">\/\/ If you modify the type in the User class, you need to manually update it here.<\/span>\r\nwatchUtils.watch(user, <span style=\"color: #d14;\">'fullName'<\/span> ,(fullName: string) =&gt; {\r\n  \/\/ Do something\r\n});\r\n\r\n<span style=\"color: #998; font-style: italic;\">\/\/ Typescript automatically infers the type of the return value of the reactive expression.<\/span>\r\nreactiveUtils.watch(\r\n  () =&gt; user.fullName,\r\n  (fullName) =&gt; { <span style=\"color: #998; font-style: italic;\">\/\/ Type inferred as string!\r\n<\/span>    \/\/ Do something\r\n  }\r\n);\r\n<\/code><\/pre>\n<p>In the first example, we are using watchUtils and we need to manually specify the type of the callback argument. If we modify the type of the fullName property in the User class, we also need to manually update the type in the watch callback. In contrast, the second example is using reactiveUtils and Typescript automatically infers the type of the fullName property based on the return value of the reactive expression. This means that you don&#8217;t have to manually specify the type, and if you modify the type in the User class, it will be automatically updated in the watch.<\/p>\n<h2>A note about refactoring from watchUtils to reactiveUtils<\/h2>\n<p>In the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-core-reactiveUtils.html\">reactiveUtils<\/a> API reference page, there are hints as to which reactiveUtils method is recommended as a replacement for each watchUtils method. There is also additional information in the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-core-reactiveUtils.html#overview\">Overview<\/a> section of the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-core-reactiveUtils.html\">reactiveUtils<\/a> API reference.<\/p>\n<h2>Conclusion<\/h2>\n<p>As we\u2019ve seen, the reactiveUtils provide valuable tools and greater flexibility for responding to changes in API objects and your own Accessor-based objects. They offer enhanced safety and bug prevention, and when used with Typescript, facilitate efficient refactoring. Compared to the now removed watchUtils, the reactiveUtils offer a superior solution for managing property and state changes in a wide range of contexts.<\/p>\n"},{"acf_fc_layout":"content","content":"<p>If you want to continue learning about reactivity, here are some recommended readings:<\/p>\n<ul>\n<li><a href=\"https:\/\/dev.to\/ryansolid\/a-hands-on-introduction-to-fine-grained-reactivity-3ndf\">A Hands-on Introduction to Fine-Grained Reactivity<\/a><\/li>\n<li><a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/programming-patterns\/#watching-for-property-changes\">Watching for property changes with the JavaScript Maps SDK<\/a><\/li>\n<li><a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-core-reactiveUtils.html\">reactiveUtils API Reference<\/a><\/li>\n<li><a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/sample-code\/?tagged=reactiveUtils\">JavaScript Maps SDK reactiveUtils samples<\/a><\/li>\n<\/ul>\n"}],"related_articles":"","card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/02\/reactiveUtilsBanner-3.png","wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/02\/reactiveUtilsBanner-2.png"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Why you should be using reactiveUtils instead of watchUtils<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Why you should be using reactiveUtils instead of watchUtils\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript\" \/>\n<meta property=\"og:site_name\" content=\"ArcGIS Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/esrigis\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T10:10:54+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@ESRI\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript\"},\"author\":{\"name\":\"Lauren Boyd\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/a93d293a2435834e9f0af1fc378528a1\"},\"headline\":\"Why you should be using reactiveUtils instead of watchUtils\",\"datePublished\":\"2023-02-23T01:00:50+00:00\",\"dateModified\":\"2024-04-12T10:10:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript\"},\"wordCount\":9,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"keywords\":[\"4.26\",\"jsapi4\"],\"articleSection\":[\"Developers\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript\",\"name\":\"Why you should be using reactiveUtils instead of watchUtils\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\"},\"datePublished\":\"2023-02-23T01:00:50+00:00\",\"dateModified\":\"2024-04-12T10:10:54+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.esri.com\/arcgis-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Why you should be using reactiveUtils instead of watchUtils\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"name\":\"ArcGIS Blog\",\"description\":\"Get insider info from Esri product teams\",\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\",\"name\":\"Esri\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"contentUrl\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png\",\"width\":400,\"height\":400,\"caption\":\"Esri\"},\"image\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/esrigis\/\",\"https:\/\/x.com\/ESRI\",\"https:\/\/www.linkedin.com\/company\/5311\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/a93d293a2435834e9f0af1fc378528a1\",\"name\":\"Lauren Boyd\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/12\/LaurenBoydBlogCropped-213x200.png\",\"contentUrl\":\"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/12\/LaurenBoydBlogCropped-213x200.png\",\"caption\":\"Lauren Boyd\"},\"description\":\"Lauren is a Senior Product Engineer on the ArcGIS Maps SDK for JavaScript team in Redlands, CA with her work focusing primarily on popups and security. She has worked at Esri for over 8 years and enjoys helping\/supporting geo-developers utilize the JavaScript Maps SDK into their awesome applications.\",\"sameAs\":[\"https:\/\/github.com\/lboyd93\",\"https:\/\/www.linkedin.com\/in\/lboyd93\/\"],\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/author\/lauren-boyd\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Why you should be using reactiveUtils instead of watchUtils","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript","og_locale":"en_US","og_type":"article","og_title":"Why you should be using reactiveUtils instead of watchUtils","og_url":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript","og_site_name":"ArcGIS Blog","article_publisher":"https:\/\/www.facebook.com\/esrigis\/","article_modified_time":"2024-04-12T10:10:54+00:00","twitter_card":"summary_large_image","twitter_site":"@ESRI","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript#article","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript"},"author":{"name":"Lauren Boyd","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/a93d293a2435834e9f0af1fc378528a1"},"headline":"Why you should be using reactiveUtils instead of watchUtils","datePublished":"2023-02-23T01:00:50+00:00","dateModified":"2024-04-12T10:10:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript"},"wordCount":9,"commentCount":0,"publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"keywords":["4.26","jsapi4"],"articleSection":["Developers"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript","url":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript","name":"Why you should be using reactiveUtils instead of watchUtils","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#website"},"datePublished":"2023-02-23T01:00:50+00:00","dateModified":"2024-04-12T10:10:54+00:00","breadcrumb":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.esri.com\/arcgis-blog\/"},{"@type":"ListItem","position":2,"name":"Why you should be using reactiveUtils instead of watchUtils"}]},{"@type":"WebSite","@id":"https:\/\/www.esri.com\/arcgis-blog\/#website","url":"https:\/\/www.esri.com\/arcgis-blog\/","name":"ArcGIS Blog","description":"Get insider info from Esri product teams","publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.esri.com\/arcgis-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization","name":"Esri","url":"https:\/\/www.esri.com\/arcgis-blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","contentUrl":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2018\/04\/Esri.png","width":400,"height":400,"caption":"Esri"},"image":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/esrigis\/","https:\/\/x.com\/ESRI","https:\/\/www.linkedin.com\/company\/5311\/"]},{"@type":"Person","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/a93d293a2435834e9f0af1fc378528a1","name":"Lauren Boyd","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/","url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/12\/LaurenBoydBlogCropped-213x200.png","contentUrl":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2022\/12\/LaurenBoydBlogCropped-213x200.png","caption":"Lauren Boyd"},"description":"Lauren is a Senior Product Engineer on the ArcGIS Maps SDK for JavaScript team in Redlands, CA with her work focusing primarily on popups and security. She has worked at Esri for over 8 years and enjoys helping\/supporting geo-developers utilize the JavaScript Maps SDK into their awesome applications.","sameAs":["https:\/\/github.com\/lboyd93","https:\/\/www.linkedin.com\/in\/lboyd93\/"],"url":"https:\/\/www.esri.com\/arcgis-blog\/author\/lauren-boyd"}]}},"text_date":"February 22, 2023","author_name":"Multiple Authors","author_page":"https:\/\/www.esri.com\/arcgis-blog\/products\/js-api-arcgis\/developers\/reactiveutils-and-why-you-should-be-using-them-instead-of-watchutils-with-the-arcgis-maps-sdk-for-javascript","custom_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2023\/02\/reactiveUtilsBanner-2.png","primary_product":"ArcGIS Maps SDK for JavaScript","tag_data":[{"term_id":768932,"name":"4.26","slug":"4-26","term_group":0,"term_taxonomy_id":768932,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"},{"term_id":27491,"name":"jsapi4","slug":"jsapi4","term_group":0,"term_taxonomy_id":27491,"taxonomy":"post_tag","description":"","parent":0,"count":111,"filter":"raw"}],"category_data":[{"term_id":738191,"name":"Developers","slug":"developers","term_group":0,"term_taxonomy_id":738191,"taxonomy":"category","description":"","parent":0,"count":423,"filter":"raw"}],"product_data":[{"term_id":761642,"name":"ArcGIS Location Platform","slug":"platform","term_group":0,"term_taxonomy_id":761642,"taxonomy":"product","description":"","parent":36601,"count":214,"filter":"raw"},{"term_id":36831,"name":"ArcGIS Maps SDK for JavaScript","slug":"js-api-arcgis","term_group":0,"term_taxonomy_id":36831,"taxonomy":"product","description":"","parent":36601,"count":363,"filter":"raw"}],"primary_product_link":"https:\/\/www.esri.com\/arcgis-blog\/?s=#&products=js-api-arcgis","_links":{"self":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/1810112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/users\/293472"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/comments?post=1810112"}],"version-history":[{"count":0,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/1810112\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/media?parent=1810112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/categories?post=1810112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/tags?post=1810112"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/industry?post=1810112"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/product?post=1810112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}