Defining your widget
With Dojo's AMD style, there are two main ways to use AMD components. Using the require()
function plays the script once, and then it's done. But if you want to create a module that can be used over and over again, you would want to define()
the module, instead. The define()
function creates one or more custom modules to be used by an application.
The define()
function takes a single argument, which could be any JavaScript object. Even define("Hello World!")
is a valid module definition, though not that useful. You can create more useful ones by passing in objects or object constructors that perform tasks for your application. Review the following example:
define(function () { var mysteryNumber = Math.floor((Math.random() * ...
Get Mastering ArcGIS Server Development with JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.