Skip to content

Commit 5595935

Browse files
committed
Add jsdoc for CallbackRegistry
1 parent a250aa7 commit 5595935

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

inst/htmlwidgets/anyhtmlwidget.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
class CallbackRegistry {
2+
/** @type {Record<string, Function[]>} */
23
#callbacks = {};
4+
/**
5+
* @param {string} name
6+
* @param {Function} callback
7+
*/
38
add(name, callback) {
49
if (!this.#callbacks[name]) {
510
this.#callbacks[name] = [];
611
}
712
this.#callbacks[name].push(callback);
813
}
14+
/**
15+
* @param {string} name
16+
* @param {Function} [callback] - a specific callback to remove
17+
* @returns {Function[]} - the removed callbacks
18+
*/
919
remove(name, callback) {
1020
if (!this.#callbacks[name]) {
1121
return [];

0 commit comments

Comments
 (0)