2022-12-02 19:08:03 +00:00
|
|
|
---
|
|
|
|
name: Module bait
|
2022-12-03 20:54:34 +00:00
|
|
|
description: the event emitter
|
2022-12-02 19:08:03 +00:00
|
|
|
layout: apidoc
|
|
|
|
---
|
|
|
|
|
|
|
|
## Introduction
|
2022-12-03 20:54:34 +00:00
|
|
|
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.
|
2022-12-02 19:08:03 +00:00
|
|
|
|
|
|
|
## Functions
|
2022-12-03 20:54:34 +00:00
|
|
|
### catch(name, cb)
|
|
|
|
Catches a hook with `name`. Runs the `cb` when it is thrown
|
2022-12-02 19:08:03 +00:00
|
|
|
|
2022-12-03 20:54:34 +00:00
|
|
|
### catchOnce(name, cb)
|
|
|
|
Same as catch, but only runs the `cb` once and then removes the hook
|
2022-12-02 19:08:03 +00:00
|
|
|
|
2022-12-03 20:54:34 +00:00
|
|
|
### hooks(name) -> {cb, cb...}
|
|
|
|
Returns a table with hooks on the event with `name`.
|
2022-12-02 19:08:03 +00:00
|
|
|
|
2022-12-03 20:54:34 +00:00
|
|
|
### release(name, catcher)
|
|
|
|
Removes the `catcher` for the event with `name`
|
|
|
|
For this to work, `catcher` has to be the same function used to catch
|
|
|
|
an event, like one saved to a variable.
|
2022-12-02 19:08:03 +00:00
|
|
|
|
2022-12-03 20:54:34 +00:00
|
|
|
### throw(name, ...args)
|
|
|
|
Throws a hook with `name` with the provided `args`
|
2022-12-03 15:15:25 +00:00
|
|
|
|