File tree 2 files changed +116
-0
lines changed
2 files changed +116
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,62 @@ Hurl.prototype.snowball = function() {
77
77
*/
78
78
{{/example}}
79
79
80
+ <p>
81
+ The following example shows how to document events in the context of AMD modules.
82
+ </p>
83
+
84
+ {{#example}}Documenting events in AMD modules
85
+ define('playground/monitor', [], function () {
86
+ /**
87
+ * Keeps an eye out for snowball-throwers.
88
+ *
89
+ * @module playground/monitor
90
+ */
91
+ var exports = {
92
+ /**
93
+ * Report the throwing of a snowball.
94
+ *
95
+ * @method
96
+ * @param {module:hurler#event:snowball} e - A snowball event.
97
+ * @listens module:hurler#snowball
98
+ */
99
+ reportThrowage: function (e) {
100
+ this.log('snowball thrown: velocity ' + e.velocity);
101
+ }
102
+ };
103
+
104
+ return exports;
105
+ });
106
+
107
+ define('hurler', [], function () {
108
+ /**
109
+ * Event reporting that a snowball has been hurled.
110
+ *
111
+ * @event module:hurler#snowball
112
+ * @property {number} velocity - The snowball's velocity, in meters per second.
113
+ */
114
+
115
+ /**
116
+ * Snowball-hurling module.
117
+ *
118
+ * @module hurler
119
+ */
120
+ var exports = {
121
+ /**
122
+ * Attack an innocent (or guilty) person with a snowball.
123
+ *
124
+ * @method
125
+ * @fires module:hurler#snowball
126
+ */
127
+ attack: function () {
128
+ this.emit('snowball', { velocity: 10 });
129
+ }
130
+ };
131
+
132
+ return exports;
133
+ });
134
+ {{/example}}
135
+
80
136
<h3>See Also</h3>
81
137
82
138
<ul>
Original file line number Diff line number Diff line change @@ -256,6 +256,66 @@ <h3>Examples</h3>
256
256
* @property {boolean} isPacked - Indicates whether the snowball is tightly packed.
257
257
*/
258
258
259
+ </ pre >
260
+ </ dd >
261
+ </ dl > < p >
262
+ The following example shows how to document events in the context of AMD modules.
263
+ </ p >
264
+
265
+ < dl class ="example ">
266
+ < dt > Documenting events in AMD modules</ dt >
267
+ < dd >
268
+ < pre class ="prettyprint lang-js ">
269
+ define('playground/monitor', [], function () {
270
+ /**
271
+ * Keeps an eye out for snowball-throwers.
272
+ *
273
+ * @module playground/monitor
274
+ */
275
+ var exports = {
276
+ /**
277
+ * Report the throwing of a snowball.
278
+ *
279
+ * @method
280
+ * @param {module:hurler#event:snowball} e - A snowball event.
281
+ * @listens module:hurler#snowball
282
+ */
283
+ reportThrowage: function (e) {
284
+ this.log('snowball thrown: velocity ' + e.velocity);
285
+ }
286
+ };
287
+
288
+ return exports;
289
+ });
290
+
291
+ define('hurler', [], function () {
292
+ /**
293
+ * Event reporting that a snowball has been hurled.
294
+ *
295
+ * @event module:hurler#snowball
296
+ * @property {number} velocity - The snowball's velocity, in meters per second.
297
+ */
298
+
299
+ /**
300
+ * Snowball-hurling module.
301
+ *
302
+ * @module hurler
303
+ */
304
+ var exports = {
305
+ /**
306
+ * Attack an innocent (or guilty) person with a snowball.
307
+ *
308
+ * @method
309
+ * @fires module:hurler#snowball
310
+ */
311
+ attack: function () {
312
+ this.emit('snowball', { velocity: 10 });
313
+ }
314
+ };
315
+
316
+ return exports;
317
+ });
318
+
259
319
</ pre >
260
320
</ dd >
261
321
</ dl > < h3 > See Also</ h3 >
You can’t perform that action at this time.
0 commit comments