How to document an event handler in JSDoc?

Suppose I have a class like this:

function myClass(q) {
  this.someFunction = function(e) {
      console.log("Click event");
  };

  jQuery(q).click(this.someFunction);
}

Is there a way to tell JSDoc that someFunction is not just a function that should be called directly, but an event handler?

I see the @event tag, but if I understand correctly, this is more for documenting the function in my class, which I consider an event (something that the client code should also register, and that my class will be launched if necessary), and not a handler event function?

+5
source share
2 answers

No, there is no way to document an event handler.

, - , , , "HANDLER EVENT".

, , , : , HTML- <strong></strong>.

, .

-3

@listenens

:

/**
 * Outputs the event that happened
 *
 * @param {MyEvent} e - The observable event.
 * @listens MyEvent
 */
function myEventLogger(e) {
    console.log(e);
}

@ .

+20

Source: https://habr.com/ru/post/1733604/


All Articles