diff --git a/docs/api/bait.md b/docs/api/bait.md index 9f32b25..1bc30b7 100644 --- a/docs/api/bait.md +++ b/docs/api/bait.md @@ -141,6 +141,8 @@ bait.throw(name, ...args) Throws a hook with `name` with the provided `args`. + + #### Parameters `string` **`name`** The name of the hook. @@ -148,5 +150,14 @@ 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. +#### Example +```lua +bait.throw('greeting', 'world') + +-- This can then be listened to via +bait.catch('gretting', function(greetTo) + print('Hello ' .. greetTo) +end) +```` diff --git a/emmyLuaDocs/bait.lua b/emmyLuaDocs/bait.lua index 699d2a5..09f3d98 100644 --- a/emmyLuaDocs/bait.lua +++ b/emmyLuaDocs/bait.lua @@ -21,6 +21,8 @@ function bait.hooks(name) end function bait.release(name, catcher) end --- Throws a hook with `name` with the provided `args`. +--- +--- function bait.throw(name, ...args) end return bait diff --git a/golibs/bait/bait.go b/golibs/bait/bait.go index b507d2b..8f24d17 100644 --- a/golibs/bait/bait.go +++ b/golibs/bait/bait.go @@ -348,6 +348,16 @@ func (b *Bait) brelease(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { // #param name string The name of the hook. // #param args ...any The arguments to pass to the hook. // Throws a hook with `name` with the provided `args`. +/* +#example +bait.throw('greeting', 'world') + +-- This can then be listened to via +bait.catch('gretting', function(greetTo) + print('Hello ' .. greetTo) +end) +#example +*/ func (b *Bait) bthrow(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { if err := c.Check1Arg(); err != nil { return nil, err