2022-12-15 04:00:54 +00:00
|
|
|
---
|
|
|
|
title: Module bait
|
|
|
|
description: the event emitter
|
|
|
|
layout: doc
|
|
|
|
menu:
|
|
|
|
docs:
|
|
|
|
parent: "API"
|
|
|
|
---
|
|
|
|
|
|
|
|
## Introduction
|
|
|
|
Bait is the event emitter for Hilbish. Why name it bait? Why not.
|
|
|
|
It throws hooks that you can catch. This is what you will use if
|
|
|
|
you want to listen in on hooks to know when certain things have
|
|
|
|
happened, like when you've changed directory, a command has failed,
|
|
|
|
etc. To find all available hooks thrown by Hilbish, see doc hooks.
|
|
|
|
|
|
|
|
## Functions
|
2023-08-26 15:30:51 +00:00
|
|
|
### bait.catch(name, cb)
|
2022-12-15 04:00:54 +00:00
|
|
|
Catches a hook with `name`. Runs the `cb` when it is thrown
|
2023-08-26 15:30:51 +00:00
|
|
|
#### Parameters
|
|
|
|
This function has no parameters.
|
2022-12-15 04:00:54 +00:00
|
|
|
|
2023-08-26 15:30:51 +00:00
|
|
|
### bait.catchOnce(name, cb)
|
2022-12-15 04:00:54 +00:00
|
|
|
Same as catch, but only runs the `cb` once and then removes the hook
|
2023-08-26 15:30:51 +00:00
|
|
|
#### Parameters
|
|
|
|
This function has no parameters.
|
2022-12-15 04:00:54 +00:00
|
|
|
|
2023-08-26 15:30:51 +00:00
|
|
|
### bait.hooks(name) -> table
|
2022-12-21 00:59:55 +00:00
|
|
|
Returns a table with hooks (callback functions) on the event with `name`.
|
2023-08-26 15:30:51 +00:00
|
|
|
#### Parameters
|
|
|
|
This function has no parameters.
|
2022-12-15 04:00:54 +00:00
|
|
|
|
2023-08-26 15:30:51 +00:00
|
|
|
### bait.release(name, catcher)
|
2023-02-07 22:19:24 +00:00
|
|
|
Removes the `catcher` for the event with `name`.
|
2022-12-15 04:00:54 +00:00
|
|
|
For this to work, `catcher` has to be the same function used to catch
|
|
|
|
an event, like one saved to a variable.
|
2023-08-26 15:30:51 +00:00
|
|
|
#### Parameters
|
|
|
|
This function has no parameters.
|
2022-12-15 04:00:54 +00:00
|
|
|
|
2023-08-26 15:30:51 +00:00
|
|
|
### bait.throw(name, ...args)
|
2022-12-15 04:00:54 +00:00
|
|
|
Throws a hook with `name` with the provided `args`
|
2023-08-26 15:30:51 +00:00
|
|
|
#### Parameters
|
|
|
|
`string` **`name`**
|
|
|
|
The name of the hook.
|
|
|
|
|
|
|
|
`any` **`args`** (This type is variadic. You can pass an infinite amount of parameters with this type.)
|
|
|
|
The arguments to pass to the hook.
|
|
|
|
|
2022-12-15 04:00:54 +00:00
|
|
|
|