Skip to content

Commit 41747d7

Browse files
committed
provide example of events in AMD modules (jsdoc/jsdoc#412)
1 parent 7c3a349 commit 41747d7

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

Diff for: Jake/articles/tags-event

+56
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,62 @@ Hurl.prototype.snowball = function() {
7777
*/
7878
{{/example}}
7979

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+
80136
<h3>See Also</h3>
81137

82138
<ul>

Diff for: tags-event.html

+60
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,66 @@ <h3>Examples</h3>
256256
* @property {boolean} isPacked - Indicates whether the snowball is tightly packed.
257257
*/
258258

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+
259319
</pre>
260320
</dd>
261321
</dl><h3>See Also</h3>

0 commit comments

Comments
 (0)