Allow any return type from listener functions

This commit is contained in:
Andreas Hocevar
2021-07-12 23:18:21 +02:00
parent 7adaf7c1b5
commit 98e63c4bf1

View File

@@ -9,13 +9,13 @@ import {listen, listenOnce, unlistenByKey} from './events.js';
* @template {string} Type * @template {string} Type
* @template {Event|import("./events/Event.js").default} EventClass * @template {Event|import("./events/Event.js").default} EventClass
* @template Return * @template Return
* @typedef {(type: Type|Type[], listener: (event: EventClass) => (void|boolean)) => Return} OnSignature * @typedef {(type: Type|Type[], listener: (event: EventClass) => ?) => Return} OnSignature
*/ */
/*** /***
* @template {string} Type * @template {string} Type
* @template Return * @template Return
* @typedef {(type: Type[], listener: (event: Event|import("./events/Event").default) => (void|boolean)) => Return} CombinedOnSignature * @typedef {(type: Type[], listener: (event: Event|import("./events/Event").default) => ?) => Return} CombinedOnSignature
*/ */
/*** /***
@@ -84,7 +84,7 @@ class Observable extends EventTarget {
/** /**
* @param {string|Array<string>} type Type. * @param {string|Array<string>} type Type.
* @param {function(?): (void|boolean)} listener Listener. * @param {function(?): ?} listener Listener.
* @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key. * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
* @protected * @protected
*/ */
@@ -103,7 +103,7 @@ class Observable extends EventTarget {
/** /**
* @param {string|Array<string>} type Type. * @param {string|Array<string>} type Type.
* @param {function(?): (void|boolean)} listener Listener. * @param {function(?): ?} listener Listener.
* @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key. * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
* @protected * @protected
*/ */
@@ -125,7 +125,7 @@ class Observable extends EventTarget {
/** /**
* Unlisten for a certain type of event. * Unlisten for a certain type of event.
* @param {string|Array<string>} type Type. * @param {string|Array<string>} type Type.
* @param {function(?): (void|boolean)} listener Listener. * @param {function(?): ?} listener Listener.
* @protected * @protected
*/ */
unInternal(type, listener) { unInternal(type, listener) {
@@ -146,7 +146,7 @@ class Observable extends EventTarget {
* Listen for a certain type of event. * Listen for a certain type of event.
* @function * @function
* @param {string|Array<string>} type The event type or array of event types. * @param {string|Array<string>} type The event type or array of event types.
* @param {function((Event|import("./events/Event").default)): (void|boolean)} listener The listener function. * @param {function((Event|import("./events/Event").default)): ?} listener The listener function.
* @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Unique key for the listener. If * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Unique key for the listener. If
* called with an array of event types as the first argument, the return * called with an array of event types as the first argument, the return
* will be an array of keys. * will be an array of keys.
@@ -158,7 +158,7 @@ Observable.prototype.on;
* Listen once for a certain type of event. * Listen once for a certain type of event.
* @function * @function
* @param {string|Array<string>} type The event type or array of event types. * @param {string|Array<string>} type The event type or array of event types.
* @param {function((Event|import("./events/Event").default)): (void|boolean)} listener The listener function. * @param {function((Event|import("./events/Event").default)): ?} listener The listener function.
* @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Unique key for the listener. If * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Unique key for the listener. If
* called with an array of event types as the first argument, the return * called with an array of event types as the first argument, the return
* will be an array of keys. * will be an array of keys.
@@ -170,7 +170,7 @@ Observable.prototype.once;
* Unlisten for a certain type of event. * Unlisten for a certain type of event.
* @function * @function
* @param {string|Array<string>} type The event type or array of event types. * @param {string|Array<string>} type The event type or array of event types.
* @param {function((Event|import("./events/Event").default)): (void|boolean)} listener The listener function. * @param {function((Event|import("./events/Event").default)): ?} listener The listener function.
* @api * @api
*/ */
Observable.prototype.un; Observable.prototype.un;