v/examples/eventbus/modules/some_module/some_module.v

34 lines
445 B
V
Raw Normal View History

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