mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
docs: fix most of the examples (ensure they at least have a valid syntax)
This commit is contained in:
@ -30,7 +30,7 @@ A module to provide eventing capabilities using pub/sub.
|
||||
The function given to `subscribe`, `subscribe_method` and `subscribe_once` must match this:
|
||||
|
||||
```v oksyntax
|
||||
fn(receiver voidptr, args voidptr, sender voidptr) {
|
||||
fn cb(receiver voidptr, args voidptr, sender voidptr) {
|
||||
}
|
||||
|
||||
// Since V can map structs to voidptr, this also works
|
||||
@ -40,7 +40,7 @@ struct ClickEvent {
|
||||
}
|
||||
|
||||
// Example case where publisher sends ClickEvent as args.
|
||||
fn onPress(receiver voidptr, e &ClickEvent, sender voidptr){
|
||||
fn on_press(receiver voidptr, e &ClickEvent, sender voidptr){
|
||||
println(e.x)
|
||||
//your code here...
|
||||
}
|
||||
@ -48,7 +48,8 @@ fn onPress(receiver voidptr, e &ClickEvent, sender voidptr){
|
||||
|
||||
## Usage
|
||||
|
||||
For **usage across modules** [check the example](https://github.com/vlang/v/tree/master/examples/eventbus).
|
||||
For **usage across modules**
|
||||
[check the example](https://github.com/vlang/v/tree/master/examples/eventbus).
|
||||
|
||||
_Note: As a general rule, you will need to **subscribe before publishing**._
|
||||
|
||||
|
Reference in New Issue
Block a user