2019-11-24 14:27:50 +03:00
|
|
|
module some_module
|
|
|
|
|
|
|
|
import (
|
|
|
|
eventbus
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
eb = eventbus.new()
|
|
|
|
)
|
|
|
|
|
2019-12-18 08:16:33 +03:00
|
|
|
pub struct Work {
|
|
|
|
pub:
|
|
|
|
hours int
|
|
|
|
}
|
|
|
|
|
2019-11-24 14:27:50 +03:00
|
|
|
pub fn do_work(){
|
2019-12-18 08:16:33 +03:00
|
|
|
work := Work{20}
|
2019-11-24 14:27:50 +03:00
|
|
|
mut params := eventbus.Params{}
|
|
|
|
for i in 0..20 {
|
|
|
|
println("working...")
|
|
|
|
if i == 15 {
|
|
|
|
params.put_string("error", "CRASH!!")
|
2019-12-18 08:16:33 +03:00
|
|
|
eb.publish("error", work, params)
|
|
|
|
eb.publish("error", work, params)
|
2019-11-24 14:27:50 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_subscriber() eventbus.Subscriber {
|
|
|
|
return eb.subscriber
|
2019-12-01 10:33:26 +03:00
|
|
|
}
|