/wiki/TagEvent.wiki

http://jsdoc-toolkit.googlecode.com/ · Unknown · 58 lines · 42 code · 16 blank · 0 comment · 0 complexity · 3b732ebccdb42d5b376b6743a0219dad MD5 · raw file

  1. #summary @event
  2. This tag is available as of release 2.1.
  3. == The @event Tag ==
  4. The `@event` tag allows you to document a function that can be fired when an event of the same name occurs.
  5. === Syntax ===
  6. {{{
  7. @event
  8. }}}
  9. * The syntax of this tag is identical to the @function tag.
  10. === Example ===
  11. You can simply tag a normal function as being an event.
  12. {{{
  13. /**
  14. * @event
  15. * @param {Boolean} clockwise
  16. */
  17. Cocktail.prototype.stir = function(clockwise) {
  18. }
  19. }}}
  20. Or, you can use a named doclet without refering to any function in your code.
  21. {{{
  22. /**
  23. * @name Cocktail#shake
  24. * @event
  25. * @param {MyEventObject} e
  26. * @param {Boolean} [e.withIce=false]
  27. */
  28. }}}
  29. === Referring to Events ===
  30. Note that, by using the named doclet method illustrated above, it is possible to have a method and an event that both have the same name. In order to disambiguate which symbol you are referring to (either the method or the event) the namepath of the event has a prefix of "event:" inserted into it.
  31. So when you need to refer to an event by it's namepath the name should be written as event:name.
  32. {{{
  33. /**
  34. * @constructor
  35. * @borrows Cocktail#event:shake as this.event:shake
  36. */
  37. function MilkShake() {
  38. }
  39. }}}
  40. === See Also ===
  41. * The [TagFunction @function] tag.
  42. * NamePaths