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

37 lines
453 B
V
Raw Normal View History

module some_module
import (
eventbus
)
const (
eb = eventbus.new()
)
2019-12-18 08:16:33 +03:00
pub struct Work {
pub:
hours int
}
2020-01-22 19:41:08 +03:00
pub struct Error {
pub:
message string
}
pub fn do_work(){
2019-12-18 08:16:33 +03:00
work := Work{20}
for i in 0..20 {
println("working...")
if i == 15 {
2020-01-22 19:41:08 +03:00
error := &Error{"There was an error."}
eb.publish("error", work, error)
eb.publish("error", work, error)
return
}
}
}
pub fn get_subscriber() eventbus.Subscriber {
return eb.subscriber
2019-12-01 10:33:26 +03:00
}