mirror of
				https://github.com/sammy-ette/Hilbish
				synced 2025-08-10 02:52:03 +00:00 
			
		
		
		
	website(docs/bait): add example for throw function
This commit is contained in:
		
							parent
							
								
									d921d3f752
								
							
						
					
					
						commit
						068ef7a376
					
				| @ -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> | ||||
| 
 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user