blob: 01231fb1933cb70c6f8034d57ca4a15294ca78b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
module some_module
import eventbus
const (
eb = eventbus.new()
)
pub struct Work {
pub:
hours int
}
pub struct MyError {
pub:
message string
}
pub fn do_work() {
work := Work{20}
for i in 0 .. 20 {
println('working...')
if i == 15 {
error := &MyError{'There was an error.'}
some_module.eb.publish('error', work, error)
some_module.eb.publish('error', work, error)
return
}
}
}
pub fn get_subscriber() eventbus.Subscriber {
return *some_module.eb.subscriber
}
|