## Webinar: Tips and Tricks for Developing and Debugging Apps Kelly Hutchins and Heather Gonzago
Ever have one of those days where nothing seems to work?
You keep staring at the same code, but you have nothing...
Debugging tools === Productive programmers
- Setting up your development environment - Troubleshoot web application - Popular browser developer tools - Give us your questions
- Lots of choices - Atom, Brackets, WebStorm, Sublime, VSCode - Debugging support - Extensions
- Beautify, Prettier
- EsLint
- Bracket colorizer
- Themes,
- GitLens
- Ligatures - Fira Code, Hasklig, Cascadia
- Templates for reuseable code - [ArcGIS API for JavaScript snippets](https://marketplace.visualstudio.com/items?itemName=Esri.arcgis-jsapi-snippets&ssr=false#overview) - [Snippet generator](https://pawelgrzybek.com/snippet-generator/)
- Emmet
- Save keystrokes
- HTML, CSS abbreviations
- Plug-in page
- Code assist - ES6 - TypeScript setup
- Setup IIS or Apache - Visit [http://localhost](http://localhost) - Local dev server with live reload: - [Live Server](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer) - [local-web-server](https://www.npmjs.com/package/local-web-server) - [http-server](https://www.npmjs.com/package/http-server) ----
- TypeScript
- WebPack
- ArcGIS API JS Template App
- Is the problem with how the code is written?
- Is the issue on the client (API) or server?
- Is there a performance issue?
- Is the issue with the data?
- Common examples of application-level problems: - Modules out of order - View, Map, Layer not ready - Typos (yes, it happens quite often)
Multiple errors can stem from wrong module order
- Has the view containing the map fully loaded before executing code?
- Has the layer fully loaded before performing specific functions?
- Wrap problem areas in
try/catch
statements for troubleshooting
// Create a MapView instance (for 2D viewing)
var view = new MapView({
map: myMap, // References a Map instance
container: "viewDiv" // References the ID of a DOM element
});
view.when(function(){
// All the resources in the MapView and the map have loaded. Now execute additional processes
}, function(error){
// Use the errback function to handle when the view doesn't load properly
console.log("The view's resources failed to load: ", error);
});
- Records all network requests
- Inspect network traffic, e.g.
- Search widget not displaying properly
- GP task not executing as expected
- Querying layer features
### Demo: Network requests
- Execute JavaScript
- Check values of objects at an app breakpoint
- Detect user color scheme preferences - CSS media feature (light, dark, no-preference) - Emulate via dev tools
- Inspect element css - View classes applied to selected element - View widget styles
## Questions?
- [https://github.com/hgonzago/tips-tricks-webinar](https://github.com/hgonzago/tips-tricks-webinar) - [ArcGIS API for JavaScript Snippets](https://github.com/hgonzago/tips-tricks-webinar) - [ArcGIS API for JavaScript Guide topic - TypeScript setup](https://developers.arcgis.com/javascript/latest/guide/typescript-setup/)