2
2
espelhamento de https://github.com/Hilbis/Hilbish sincronizado 2025-07-11 05:22:02 +00:00

website(docs/bait): add example for throw function

Esse commit está contido em:
sammyette 2023-11-30 22:09:07 -04:00
commit 068ef7a376
Assinado por: sammyette
ID da chave GPG: 904FC49417B44DCD
3 arquivos alterados com 23 adições e 0 exclusões

Ver arquivo

@ -141,6 +141,8 @@ bait.throw(name, ...args)
</h4>
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)
````
</div>

Ver arquivo

@ -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

Ver arquivo

@ -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