{"id":80961,"date":"2017-12-14T10:57:13","date_gmt":"2017-12-14T10:57:13","guid":{"rendered":"http:\/\/www.esri.com\/arcgis-blog\/products\/product\/uncategorized\/making-better-promises\/"},"modified":"2020-02-12T19:13:32","modified_gmt":"2020-02-13T03:13:32","slug":"making-better-promises","status":"publish","type":"blog","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises","title":{"rendered":"Making Better Promises"},"author":7451,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"_acf_changed":false,"_searchwp_excluded":""},"categories":[22941],"tags":[35031,42621,24921,27491,42741],"industry":[],"product":[36831,36601],"class_list":["post-80961","blog","type-blog","status-publish","format-standard","hentry","category-mapping","tag-4-6","tag-4-7","tag-javascript","tag-jsapi4","tag-promises","product-js-api-arcgis","product-developers"],"acf":{"short_description":"This blog post will discuss a change to our implementation of promises, a change towards making a better promise. ","flexible_content":[{"acf_fc_layout":"content","content":"<p><strong>Updated April 2018<\/strong>: For the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/guide\/release-notes\/index.html\" target=\"_blank\" rel=\"noopener\">4.7 release<\/a> of the ArcGIS API for JavaScript, which improves our compatibility with ES Promises.<\/p>\n<p>At the <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/guide\/release-notes\/index.html#better-support-for-es-promises\" target=\"_blank\" rel=\"noopener\">4.7 release<\/a>, we made the API compatible with ES promises by default. You are still able to opt-out by setting the <strong>has<\/strong> flag to zero:<\/p>\n<pre><span style=\"color: #000080; font-weight: normal;\">&lt;<span style=\"color: #000080; font-weight: normal;\">script<\/span>&gt;<\/span>\r\n  <span style=\"color: #333; font-weight: bold;\">var<\/span> dojoConfig = {\r\n    has: {\r\n      <span style=\"color: #d14;\">\"esri-promise-compatibility\"<\/span>: <span style=\"color: #008080;\">0<\/span>\r\n    }\r\n  };\r\n<span style=\"color: #000080; font-weight: normal;\">&lt;\/<span style=\"color: #000080; font-weight: normal;\">script<\/span>&gt;<\/span>\r\n\r\n <span style=\"color: #000080; font-weight: normal;\">&lt;<span style=\"color: #000080; font-weight: normal;\">link<\/span> <span style=\"color: #008080;\">rel<\/span>=<span style=\"color: #d14;\">\"stylesheet\"<\/span> <span style=\"color: #008080;\">href<\/span>=<span style=\"color: #d14;\">\"https:\/\/js.arcgis.com\/4.7\/esri\/css\/main.css\"<\/span>&gt;<\/span>\r\n <span style=\"color: #000080; font-weight: normal;\">&lt;<span style=\"color: #000080; font-weight: normal;\">script<\/span> <span style=\"color: #008080;\">src<\/span>=<span style=\"color: #d14;\">\"https:\/\/js.arcgis.com\/4.7\/\"<\/span>&gt;<\/span><span style=\"color: #000080; font-weight: normal;\">&lt;\/<span style=\"color: #000080; font-weight: normal;\">script<\/span>&gt;<\/span>\r\n<\/pre>\n<p>At version 4.8, we will remove the ability to opt-out of ES promise compatibility.<\/p>\n<p>At 4.7, we removed <code>then()<\/code> as a method in our API, and similarly deprecated <code>always()<\/code> and <code>otherwise()<\/code> as API methods (both of which will be removed from the API at the next release). This functionality can still be achieved using <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/index.html?search=when\" target=\"_blank\" rel=\"noopener\">when()<\/a>.<\/p>\n"},{"acf_fc_layout":"image","image":{"ID":157481,"id":157481,"title":"PromiseTable","filename":"PromiseTable.png","filesize":10269,"url":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2017\/12\/PromiseTable.png","link":"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises\/promisetable-2","alt":"","author":"7451","description":"These methods only apply to API methods. Native JavaScript implementations will continue to function.","caption":"These methods only apply to API methods. Native JavaScript implementations will continue to function.","name":"promisetable-2","status":"inherit","uploaded_to":80961,"date":"2018-04-19 17:33:03","modified":"2018-04-19 17:33:16","menu_order":0,"mime_type":"image\/png","type":"image","subtype":"png","icon":"https:\/\/www.esri.com\/arcgis-blog\/wp-includes\/images\/media\/default.png","width":729,"height":154,"sizes":{"thumbnail":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2017\/12\/PromiseTable.png","thumbnail-width":213,"thumbnail-height":45,"medium":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2017\/12\/PromiseTable.png","medium-width":464,"medium-height":98,"medium_large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2017\/12\/PromiseTable.png","medium_large-width":729,"medium_large-height":154,"large":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2017\/12\/PromiseTable.png","large-width":729,"large-height":154,"1536x1536":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2017\/12\/PromiseTable.png","1536x1536-width":729,"1536x1536-height":154,"2048x2048":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2017\/12\/PromiseTable.png","2048x2048-width":729,"2048x2048-height":154,"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2017\/12\/PromiseTable.png","card_image-width":729,"card_image-height":154,"wide_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2017\/12\/PromiseTable.png","wide_image-width":729,"wide_image-height":154}},"image_position":"center","orientation":"horizontal","hyperlink":""},{"acf_fc_layout":"content","content":"<p><strong>Original Post: December 2017<\/strong><\/p>\n"},{"acf_fc_layout":"content","content":"<p>This blog post will discuss a change to our implementation of promises, a change towards making a better promise. Numerous classes in the ArcGIS API for JavaScript\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/guide\/programming-patterns\/#async-data\" target=\"_blank\" rel=\"noopener\">resolve to promises<\/a>. This is the case for\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-WebMap.html#then\" target=\"_blank\" rel=\"noopener\">WebMap<\/a>,\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-WebScene.html#then\" target=\"_blank\" rel=\"noopener\">WebScene<\/a>,\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-views-MapView.html#then\" target=\"_blank\" rel=\"noopener\">MapView<\/a>,\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-views-SceneView.html#then\" target=\"_blank\" rel=\"noopener\">SceneView<\/a>,\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-Basemap.html#then\" target=\"_blank\" rel=\"noopener\">Basemap<\/a>,\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-Ground.html#then\" target=\"_blank\" rel=\"noopener\">Ground<\/a>,\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-layers-Layer.html#then\" target=\"_blank\" rel=\"noopener\">Layers<\/a>, and\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/esri-views-layers-LayerView.html#then\" target=\"_blank\" rel=\"noopener\">LayerViews<\/a>.<\/p>\n<p>Typically, you would use the\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/index.html?search=then\" target=\"_blank\" rel=\"noopener\">then()<\/a>\u00a0method to be advised when one of these objects is ready to be used. In fact,\u00a0<a title=\"Intro to layers\" href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/sample-code\/sandbox\/index.html?sample=intro-layers\" target=\"_blank\" rel=\"noopener\">many samples<\/a>\u00a0in the ArcGIS API\u00a0for JavaScript SDK\u00a0use\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/index.html?search=then\" target=\"_blank\" rel=\"noopener\">then()<\/a>\u00a0on a MapView or on a SceneView to wait for the view to be ready before executing the rest of the application code.<br \/>\n<!--more--><\/p>\n<pre>view.then(<span style=\"color: #333; font-weight: bold;\">function<\/span>(){\r\n  <span style=\"color: #998; font-style: italic;\">\/\/ do something with loaded view properties here<\/span>\r\n});<\/pre>\n<p>Unfortunately, the\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/index.html?search=then\" target=\"_blank\" rel=\"noopener\">then()<\/a>\u00a0method on the above classes is not compatible when used with native\u00a0<a title=\"JavaScript Promise\" href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Promise\" target=\"_blank\" rel=\"noopener\">JavaScript Promises<\/a>. The\u00a0web browser will go into an infinite loop, which will make it unresponsive.\u00a0The example below reproduces the issue. The function returns a Promise, which is supposed to resolve with a newly created WebMap.<\/p>\n<pre><span style=\"color: #333; font-weight: bold;\">function<\/span> <span style=\"color: #900; font-weight: bold;\">createWebMap<\/span>(itemId) {\r\n  <span style=\"color: #333; font-weight: bold;\">var<\/span> webmap = <span style=\"color: #333; font-weight: bold;\">new<\/span> WebMap({\r\n    portalItem: {\r\n      id: itemId\r\n    }\r\n  });\r\n\r\n  <span style=\"color: #998; font-style: italic;\">\/\/ The browser go into an infinite loop.<\/span>\r\n  <span style=\"color: #333; font-weight: bold;\">return<\/span> <span style=\"color: #0086b3;\">Promise<\/span>.resolve(webmap);\r\n}<\/pre>\n<p>To understand why this is so important, it&#8217;s necessary to know how native\u00a0<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Guide\/Using_promises#Chaining\" target=\"_blank\" rel=\"noopener\">JavaScript Promise chaining<\/a>\u00a0works. When a promise resolves with a result object that exposes a\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/index.html?search=then\" target=\"_blank\" rel=\"noopener\">then()<\/a>\u00a0method, the Promise calls it to chain automatically. In our ArcGIS API for JavaScript, WebMap and other similar classes resolves with themselves.<\/p>\n<pre>webmap.then(<span style=\"color: #333; font-weight: bold;\">function<\/span>(webmap){\r\n  <span style=\"color: #998; font-style: italic;\">\/\/ webmap is resolved with itself, which also a promise<\/span>\r\n});<\/pre>\n<p>Back when 4.0 development started, this wasn&#8217;t an issue. Since then, the JavaScript Promises have been standardized and more developers have confronted this issue. So to improve the compatibility with JavaScript Promises,\u00a0<strong>we decided to roll out a breaking change by renaming <a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/index.html?search=then\" target=\"_blank\" rel=\"noopener\">then()<\/a> on all applicable classes to\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/index.html?search=when\" target=\"_blank\" rel=\"noopener\">when()<\/a><\/strong>.<\/p>\n<pre>view.when(<span style=\"color: #333; font-weight: bold;\">function<\/span>(){\r\n  <span style=\"color: #998; font-style: italic;\">\/\/ do something with loaded view properties here<\/span>\r\n});<\/pre>\n<p>The\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/index.html?search=then\" target=\"_blank\" rel=\"noopener\">then()<\/a>\u00a0method will still work at 4.6, but will throw warnings in the browser console.\u00a0To prevent these warning messages from appearing, please insert the below <strong>has<\/strong> flag into your code.\u00a0<strong>Because this is an important breaking change, we are not removing then() at 4.6, and will instead remove then() at a later version.<\/strong><\/p>\n<p>Note: this change only affects the classes that implement a\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/index.html?search=then\" target=\"_blank\" rel=\"noopener\">then()<\/a>\u00a0method. Other asynchronous methods and function are still fully using promises.<\/p>\n<p>While\u00a0<a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/api-reference\/index.html?search=when\" target=\"_blank\" rel=\"noopener\">when()<\/a>\u00a0should be used at 4.6 on all applicable classes, you must specify the following\u00a0<strong>has<\/strong>\u00a0flag prior to loading the ArcGIS API for JavaScript for your application to be compatible with native JavaScript Promises. This must be loaded prior to loading the API.<\/p>\n<pre><span style=\"color: #000080; font-weight: normal;\">&lt;<span style=\"color: #000080; font-weight: normal;\">script<\/span>&gt;<\/span>\r\n  <span style=\"color: #333; font-weight: bold;\">var<\/span> dojoConfig = {\r\n    has: {\r\n      <span style=\"color: #d14;\">\"esri-promise-compatibility\"<\/span>: <span style=\"color: #008080;\">1<\/span>\r\n    }\r\n  };\r\n<span style=\"color: #000080; font-weight: normal;\">&lt;\/<span style=\"color: #000080; font-weight: normal;\">script<\/span>&gt;<\/span>\r\n\r\n <span style=\"color: #000080; font-weight: normal;\">&lt;<span style=\"color: #000080; font-weight: normal;\">link<\/span> <span style=\"color: #008080;\">rel<\/span>=<span style=\"color: #d14;\">\"stylesheet\"<\/span> <span style=\"color: #008080;\">href<\/span>=<span style=\"color: #d14;\">\"https:\/\/js.arcgis.com\/4.6\/esri\/css\/main.css\"<\/span>&gt;<\/span>\r\n <span style=\"color: #000080; font-weight: normal;\">&lt;<span style=\"color: #000080; font-weight: normal;\">script<\/span> <span style=\"color: #008080;\">src<\/span>=<span style=\"color: #d14;\">\"https:\/\/js.arcgis.com\/4.6\/\"<\/span>&gt;<\/span><span style=\"color: #000080; font-weight: normal;\">&lt;\/<span style=\"color: #000080; font-weight: normal;\">script<\/span>&gt;<\/span>\r\n<\/pre>\n<p>Additionally, this change will allow you to take advantage of\u00a0<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Operators\/await\" target=\"_blank\" rel=\"noopener\">async\/await<\/a>\u00a0alongside the ArcGIS API for JavaScript to write asynchronous code that looks synchronous:<\/p>\n<pre><span style=\"color: #333; font-weight: bold;\">var<\/span> map = <span style=\"color: #333; font-weight: bold;\">new<\/span> WebMap({\r\n  portalItem: {\r\n    id: <span style=\"color: #d14;\">\"someid\"<\/span>\r\n  }\r\n});\r\n\r\n<span style=\"color: #333; font-weight: bold;\">await<\/span> map.load();\r\n<span style=\"color: #998; font-style: italic;\">\/\/ the code waits for map to load<\/span>\r\n\r\n<span style=\"color: #333; font-weight: bold;\">var<\/span> view = <span style=\"color: #333; font-weight: bold;\">new<\/span> MapView({\r\n  container: <span style=\"color: #d14;\">\"viewDiv\"<\/span>,\r\n  map: map\r\n});\r\n\r\n<span style=\"color: #333; font-weight: bold;\">await<\/span> view.when();\r\n<span style=\"color: #998; font-style: italic;\">\/\/ do something with the view<\/span><\/pre>\n<p>In conclusion, promises are an important part of the ArcGIS API for JavaScript. We feel that it is worth the effort to update how we handle promises in order to be more collaborative with the JavaScript and Web GIS communities. Please see the\u00a0<strong><a href=\"https:\/\/developers.arcgis.com\/javascript\/latest\/guide\/release-notes\/4.6\/index.html\" target=\"_blank\" rel=\"noopener\">4.6 Release Notes<\/a><\/strong>\u00a0for even more exciting changes to the ArcGIS API for JavaScript.<\/p>\n"}],"authors":[{"ID":7451,"user_firstname":"Noah","user_lastname":"Sager","nickname":"Noah Sager","user_nicename":"noah-sager","display_name":"Noah Sager","user_email":"NSager@esri.com","user_url":"https:\/\/www.noahsager.net\/","user_registered":"2018-03-21 18:21:19","user_description":"Passionate about JavaScript, maps, and writing (not necessarily in that order). Big fan of squirrels. Journeyman mapper of Utility Lines and Public Restrooms. Product Engineer on the ArcGIS API for JavaScript team. In Noah\u2019s spare time, he also enjoys parenting.","user_avatar":"<img alt='' src='https:\/\/secure.gravatar.com\/avatar\/6807cdccf3ddd5b30b84cdf9368ce6736c3d0ff9bd0a09c1f5efc03253069b64?s=96&#038;d=blank&#038;r=g' srcset='https:\/\/secure.gravatar.com\/avatar\/6807cdccf3ddd5b30b84cdf9368ce6736c3d0ff9bd0a09c1f5efc03253069b64?s=192&#038;d=blank&#038;r=g 2x' class='avatar avatar-96 photo' height='96' width='96' loading='lazy' decoding='async'\/>"},{"ID":7791,"user_firstname":"Yann","user_lastname":"Cabon","nickname":"YCabon","user_nicename":"ycabon","display_name":"Yann Cabon","user_email":"YCabon@esri.com","user_url":"","user_registered":"2018-04-12 18:23:30","user_description":"Lead Developer on the ArcGIS API for JavaScript 4.x","user_avatar":"<img alt='' src='https:\/\/secure.gravatar.com\/avatar\/3b3c9e03675f6e6a0e122dd21d383e6097c894a955c446de912e7b9c3b11221f?s=96&#038;d=blank&#038;r=g' srcset='https:\/\/secure.gravatar.com\/avatar\/3b3c9e03675f6e6a0e122dd21d383e6097c894a955c446de912e7b9c3b11221f?s=192&#038;d=blank&#038;r=g 2x' class='avatar avatar-96 photo' height='96' width='96' loading='lazy' decoding='async'\/>"}],"related_articles":[{"ID":140441,"post_author":"7451","post_date":"2018-04-19 17:30:15","post_date_gmt":"2018-04-19 17:30:15","post_content":"","post_title":"ArcGIS API for JavaScript versions 4.7 and 3.24 released","post_excerpt":"","post_status":"publish","comment_status":"closed","ping_status":"closed","post_password":"","post_name":"arcgis-api-for-javascript-versions-4-7-and-3-24-released","to_ping":"","pinged":"","post_modified":"2018-05-07 16:18:46","post_modified_gmt":"2018-05-07 16:18:46","post_content_filtered":"","post_parent":0,"guid":"http:\/\/www.esri.com\/arcgis-blog\/?post_type=blog&#038;p=140441","menu_order":0,"post_type":"blog","post_mime_type":"","comment_count":"0","filter":"raw"},{"ID":80871,"post_author":"5111","post_date":"2017-12-14 10:55:28","post_date_gmt":"2017-12-14 10:55:28","post_content":"","post_title":"ArcGIS API for JavaScript versions 4.6 and 3.23 released","post_excerpt":"","post_status":"publish","comment_status":"closed","ping_status":"closed","post_password":"","post_name":"arcgis-api-for-javascript-versions-4-6-and-3-23-released","to_ping":"","pinged":"","post_modified":"2018-05-31 19:51:12","post_modified_gmt":"2018-05-31 19:51:12","post_content_filtered":"","post_parent":0,"guid":"http:\/\/www.esri.com\/arcgis-blog\/products\/product\/uncategorized\/arcgis-api-for-javascript-versions-4-6-and-3-23-released\/","menu_order":0,"post_type":"blog","post_mime_type":"","comment_count":"0","filter":"raw"}],"card_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2017\/12\/LiveByTheCode.jpg","wide_image":false},"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>Making Better Promises<\/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\/mapping\/mapping\/making-better-promises\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Making Better Promises\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises\" \/>\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=\"2020-02-13T03:13:32+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\/mapping\/mapping\/making-better-promises#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises\"},\"author\":{\"name\":\"Noah Sager\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/31358cd525c152696fcd5fe96f49e068\"},\"headline\":\"Making Better Promises\",\"datePublished\":\"2017-12-14T10:57:13+00:00\",\"dateModified\":\"2020-02-13T03:13:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises\"},\"wordCount\":3,\"publisher\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#organization\"},\"keywords\":[\"4.6\",\"4.7\",\"JavaScript\",\"jsapi4\",\"promises\"],\"articleSection\":[\"Mapping\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises\",\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises\",\"name\":\"Making Better Promises\",\"isPartOf\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#website\"},\"datePublished\":\"2017-12-14T10:57:13+00:00\",\"dateModified\":\"2020-02-13T03:13:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.esri.com\/arcgis-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Making Better Promises\"}]},{\"@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\/31358cd525c152696fcd5fe96f49e068\",\"name\":\"Noah Sager\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6807cdccf3ddd5b30b84cdf9368ce6736c3d0ff9bd0a09c1f5efc03253069b64?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6807cdccf3ddd5b30b84cdf9368ce6736c3d0ff9bd0a09c1f5efc03253069b64?s=96&d=blank&r=g\",\"caption\":\"Noah Sager\"},\"description\":\"Passionate about JavaScript, maps, and writing (not necessarily in that order). Big fan of squirrels. Journeyman mapper of Utility Lines and Public Restrooms. Product Engineer on the ArcGIS API for JavaScript team. In Noah\u2019s spare time, he also enjoys parenting.\",\"sameAs\":[\"https:\/\/www.noahsager.net\/\",\"https:\/\/www.linkedin.com\/in\/noah-sager\",\"https:\/\/x.com\/noashx\"],\"url\":\"https:\/\/www.esri.com\/arcgis-blog\/author\/noah-sager\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Making Better Promises","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\/mapping\/mapping\/making-better-promises","og_locale":"en_US","og_type":"article","og_title":"Making Better Promises","og_url":"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises","og_site_name":"ArcGIS Blog","article_publisher":"https:\/\/www.facebook.com\/esrigis\/","article_modified_time":"2020-02-13T03:13:32+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\/mapping\/mapping\/making-better-promises#article","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises"},"author":{"name":"Noah Sager","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/31358cd525c152696fcd5fe96f49e068"},"headline":"Making Better Promises","datePublished":"2017-12-14T10:57:13+00:00","dateModified":"2020-02-13T03:13:32+00:00","mainEntityOfPage":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises"},"wordCount":3,"publisher":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#organization"},"keywords":["4.6","4.7","JavaScript","jsapi4","promises"],"articleSection":["Mapping"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises","url":"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises","name":"Making Better Promises","isPartOf":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/#website"},"datePublished":"2017-12-14T10:57:13+00:00","dateModified":"2020-02-13T03:13:32+00:00","breadcrumb":{"@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.esri.com\/arcgis-blog\/"},{"@type":"ListItem","position":2,"name":"Making Better Promises"}]},{"@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\/31358cd525c152696fcd5fe96f49e068","name":"Noah Sager","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/arcgis-blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6807cdccf3ddd5b30b84cdf9368ce6736c3d0ff9bd0a09c1f5efc03253069b64?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6807cdccf3ddd5b30b84cdf9368ce6736c3d0ff9bd0a09c1f5efc03253069b64?s=96&d=blank&r=g","caption":"Noah Sager"},"description":"Passionate about JavaScript, maps, and writing (not necessarily in that order). Big fan of squirrels. Journeyman mapper of Utility Lines and Public Restrooms. Product Engineer on the ArcGIS API for JavaScript team. In Noah\u2019s spare time, he also enjoys parenting.","sameAs":["https:\/\/www.noahsager.net\/","https:\/\/www.linkedin.com\/in\/noah-sager","https:\/\/x.com\/noashx"],"url":"https:\/\/www.esri.com\/arcgis-blog\/author\/noah-sager"}]}},"text_date":"December 14, 2017","author_name":"Multiple Authors","author_page":"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/making-better-promises","custom_image":"https:\/\/www.esri.com\/arcgis-blog\/app\/uploads\/2025\/08\/Newsroom-Keyart-Wide-1920-x-1080.jpg","primary_product":"ArcGIS Maps SDK for JavaScript","tag_data":[{"term_id":35031,"name":"4.6","slug":"4-6","term_group":0,"term_taxonomy_id":35031,"taxonomy":"post_tag","description":"","parent":0,"count":4,"filter":"raw"},{"term_id":42621,"name":"4.7","slug":"4-7","term_group":0,"term_taxonomy_id":42621,"taxonomy":"post_tag","description":"","parent":0,"count":2,"filter":"raw"},{"term_id":24921,"name":"JavaScript","slug":"javascript","term_group":0,"term_taxonomy_id":24921,"taxonomy":"post_tag","description":"","parent":0,"count":151,"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"},{"term_id":42741,"name":"promises","slug":"promises","term_group":0,"term_taxonomy_id":42741,"taxonomy":"post_tag","description":"","parent":0,"count":1,"filter":"raw"}],"category_data":[{"term_id":22941,"name":"Mapping","slug":"mapping","term_group":0,"term_taxonomy_id":22941,"taxonomy":"category","description":"","parent":0,"count":2698,"filter":"raw"}],"product_data":[{"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"},{"term_id":36601,"name":"Developers","slug":"developers","term_group":0,"term_taxonomy_id":36601,"taxonomy":"product","description":"","parent":0,"count":765,"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\/80961","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\/7451"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/comments?post=80961"}],"version-history":[{"count":0,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/blog\/80961\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/media?parent=80961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/categories?post=80961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/tags?post=80961"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/industry?post=80961"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/www.esri.com\/arcgis-blog\/wp-json\/wp\/v2\/product?post=80961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}