mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
improve eventbus
This commit is contained in:

committed by
Alexander Medvednikov

parent
136c469ef7
commit
43ba6766ba
@ -13,19 +13,22 @@ pub struct Work {
|
||||
hours int
|
||||
}
|
||||
|
||||
pub struct Error {
|
||||
pub:
|
||||
message string
|
||||
}
|
||||
|
||||
pub fn do_work(){
|
||||
work := Work{20}
|
||||
mut params := eventbus.Params{}
|
||||
for i in 0..20 {
|
||||
println("working...")
|
||||
if i == 15 {
|
||||
params.put_string("error", "CRASH!!")
|
||||
eb.publish("error", work, params)
|
||||
eb.publish("error", work, params)
|
||||
error := &Error{"There was an error."}
|
||||
eb.publish("error", work, error)
|
||||
eb.publish("error", work, error)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pub fn get_subscriber() eventbus.Subscriber {
|
||||
|
Reference in New Issue
Block a user