mirror of https://github.com/Hilbis/Hilbish
website(docs/bait): add example for throw function
parent
d921d3f752
commit
068ef7a376
|
@ -141,6 +141,8 @@ bait.throw(name, ...args)
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
Throws a hook with `name` with the provided `args`.
|
Throws a hook with `name` with the provided `args`.
|
||||||
|
|
||||||
|
|
||||||
#### Parameters
|
#### Parameters
|
||||||
`string` **`name`**
|
`string` **`name`**
|
||||||
The name of the hook.
|
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.)
|
`any` **`args`** (This type is variadic. You can pass an infinite amount of parameters with this type.)
|
||||||
The arguments to pass to the hook.
|
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>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ function bait.hooks(name) end
|
||||||
function bait.release(name, catcher) end
|
function bait.release(name, catcher) end
|
||||||
|
|
||||||
--- Throws a hook with `name` with the provided `args`.
|
--- Throws a hook with `name` with the provided `args`.
|
||||||
|
---
|
||||||
|
---
|
||||||
function bait.throw(name, ...args) end
|
function bait.throw(name, ...args) end
|
||||||
|
|
||||||
return bait
|
return bait
|
||||||
|
|
|
@ -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 name string The name of the hook.
|
||||||
// #param args ...any The arguments to pass to the hook.
|
// #param args ...any The arguments to pass to the hook.
|
||||||
// Throws a hook with `name` with the provided `args`.
|
// 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) {
|
func (b *Bait) bthrow(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||||
if err := c.Check1Arg(); err != nil {
|
if err := c.Check1Arg(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue