vgui/60-bind.js
/**
* Convenience methods to work with binds
*/
export class bind {
/**
* Registers a new bind
* @param {!string} name - The name of the bind
* @param {!string} type - The type of the bind
* @param {!Function} callback - The callback function to use
*/
static register(name, type, callback) {
if (!name)
throw new Error("Name argument not set");
if (!type)
throw new Error("Type argument not set");
if (!callback)
throw new Error("Callback argument not set");
document.addEventListener("BindEvent", function (e) {
if (e.key != name)
return
callback(e.value)
})
document.registerBind(name, type)
}
}