DiagnosticsReferenceNew · 0.744
registercallback
Store a named local callback in the diagnostics registry.
Details#
Keeps a function reference under the supplied name. Registering the same name again replaces the previous reference. This operation stores the function; it does not invoke it or attach it to an event.
Signature#
registercallback(name: string, callback: function): booleanParameters#
| Parameter | Type | Description |
|---|---|---|
name | string | Registry key. Use a plain name without embedded NUL bytes. |
callback | function | Function reference to retain until replacement or removal. |
Returns#
true after registration. A missing name or a non-function second argument raises an argument error.
Examples#
Register and release a callback without running it
local called = false
assert(registercallback("docs.local-example", function()
called = true
end))
assert(called == false) -- registration does not call the function
assert(unregistercallback("docs.local-example"))Notes#
- Registering a callback does not run it. Remove unused callbacks with unregistercallback.