Reusable code for ArcGIS JavaScript API