Skip to main content

@event

Syntax

@event ClassName#eventName

Overview

@event documents a named event. An event doclet is typically a standalone comment block that describes what the event carries. Use @fires on a function to indicate which events it emits, and @listens on a handler to indicate which events it responds to.

Example

/**
* Fired when a record is saved successfully.
* @event Database#saved
* @type {Object}
* @property {number} id - The ID of the saved record.
* @property {Date} timestamp - When the record was saved.
*/

class Database {
/**
* Save a record to the database.
* @param {Object} record
* @fires Database#saved
*/
save(record) {
// ...
this.emit('saved', { id: record.id, timestamp: new Date() });
}
}

See also

Official reference: jsdoc.app/tags-event