2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-04-28 00:13:23 +00:00

Add docs for Bait

sammy 2021-03-30 20:05:25 -04:00
parent ecf5fe066a
commit 2d0cc225e5

29
Bait.md Normal file

@ -0,0 +1,29 @@
Bait is the event emitter for Hilbish. Why name it bait? Because it throws hooks that you can catch.
(emits events that you can listen to) and because why not, fun naming is fun.
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 require:
```lua
local bait = require 'bait'
```
# Functions
### Bait.throw(hookname, args)
Throws (emits) a new hook to catch.
`args` is the arguments that will be provided to the `hookfunc` in `Bait.catch`
#### Example
```lua
bait.throw('hello', 'world!')
```
### Bait.catch(hookname, hookfunc)
Binds a new hook named `hookname` to `hookfunc`.
#### Example
```lua
bait.catch('hello', function(name)
print('Hello ' .. name .. '!')
end)
```