1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

improve eventbus

This commit is contained in:
Abdullah Atta
2020-01-22 21:41:08 +05:00
committed by Alexander Medvednikov
parent 136c469ef7
commit 43ba6766ba
6 changed files with 115 additions and 274 deletions

View File

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