<ahref=#introductionclass=heading-link><iclass="fas fa-paperclip"></i></a></h3><p>Bait is the event emitter for Hilbish. Much like Node.js and
its <code>events</code> system, many actions in Hilbish emit events.
Unlike Node.js, Hilbish events are global. So make sure to
pick a unique name!</p><p>Usage of the Bait module consists of userstanding
event-driven architecture, but it’s pretty simple:
If you want to act on a certain event, you can <code>catch</code> it.
You can act on events via callback functions.</p><p>Examples of this are in the Hilbish default config!
Consider this part of it:</p><divclass=highlight><pretabindex=0class=chroma><codeclass=language-luadata-lang=lua><spanclass=line><spanclass=ln>1</span><spanclass=cl><spanclass=n>bait.catch</span><spanclass=p>(</span><spanclass=s1>'command.exit'</span><spanclass=p>,</span><spanclass=kr>function</span><spanclass=p>(</span><spanclass=n>code</span><spanclass=p>)</span>
</span></span></code></pre></div><p>What this does is, whenever the <code>command.exit</code> event is thrown,
this function will set the user prompt.</p><h3id=functionsclass=heading>Functions
<ahref=#functionsclass=heading-link><iclass="fas fa-paperclip"></i></a></h3><table><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><ahref=#catch>catch(name, cb)</a></td><td>Catches an event. This function can be used to act on events.</td></tr><tr><td><ahref=#catchOnce>catchOnce(name, cb)</a></td><td>Catches an event, but only once. This will remove the hook immediately after it runs for the first time.</td></tr><tr><td><ahref=#hooks>hooks(name) -> table</a></td><td>Returns a table of functions that are hooked on an event with the corresponding <code>name</code>.</td></tr><tr><td><ahref=#release>release(name, catcher)</a></td><td>Removes the <code>catcher</code> for the event with <code>name</code>.</td></tr><tr><td><ahref=#throw>throw(name, …args)</a></td><td>Throws a hook with <code>name</code> with the provided <code>args</code>.</td></tr></tbody></table><hr><divid=catch><h4class=heading>bait.catch(name, cb)
<ahref=#catchclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Catches an event. This function can be used to act on events.</p><h5id=parametersclass=heading>Parameters
<ahref=#parametersclass=heading-link><iclass="fas fa-paperclip"></i></a></h5><p><code>string</code><strong><code>name</code></strong><br>The name of the hook.</p><p><code>function</code><strong><code>cb</code></strong><br>The function that will be called when the hook is thrown.</p><h5id=exampleclass=heading>Example
<ahref=#catchOnceclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Catches an event, but only once. This will remove the hook immediately after it runs for the first time.</p><h5id=parameters-1class=heading>Parameters
<ahref=#parameters-1class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p><code>string</code><strong><code>name</code></strong><br>The name of the event</p><p><code>function</code><strong><code>cb</code></strong><br>The function that will be called when the event is thrown.</p></div><hr><divid=hooks><h4class=heading>bait.hooks(name) -> table
<ahref=#hooksclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Returns a table of functions that are hooked on an event with the corresponding <code>name</code>.</p><h5id=parameters-2class=heading>Parameters
<ahref=#parameters-2class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p><code>string</code><strong><code>name</code></strong><br>The name of the hook</p></div><hr><divid=release><h4class=heading>bait.release(name, catcher)
<ahref=#releaseclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Removes the <code>catcher</code> for the event with <code>name</code>.<br>For this to work, <code>catcher</code> has to be the same function used to catch<br>an event, like one saved to a variable.</p><h5id=parameters-3class=heading>Parameters
<ahref=#parameters-3class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p><code>string</code><strong><code>name</code></strong><br>Name of the event the hook is on</p><p><code>function</code><strong><code>catcher</code></strong><br>Hook function to remove</p><h5id=example-1class=heading>Example
<ahref=#throwclass=heading-link><iclass="fas fa-paperclip"></i></a></h4><p>Throws a hook with <code>name</code> with the provided <code>args</code>.</p><h5id=parameters-4class=heading>Parameters
<ahref=#parameters-4class=heading-link><iclass="fas fa-paperclip"></i></a></h5><p><code>string</code><strong><code>name</code></strong><br>The name of the hook.</p><p><code>any</code><strong><code>args</code></strong> (This type is variadic. You can pass an infinite amount of parameters with this type.)<br>The arguments to pass to the hook.</p><h5id=example-2class=heading>Example