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

eventbus: add generic support for event name (#18805)

This commit is contained in:
kbkpbot
2023-07-08 03:33:57 +08:00
committed by GitHub
parent 97a726b188
commit b3a6b73306
5 changed files with 119 additions and 59 deletions

View File

@ -3,7 +3,7 @@ module some_module
import eventbus
const (
eb = eventbus.new()
eb = eventbus.new[string]()
)
pub struct Duration {
@ -29,6 +29,6 @@ pub fn do_work() {
some_module.eb.publish('event_baz', &Duration{42}, &EventMetadata{'Additional data at the end.'})
}
pub fn get_subscriber() eventbus.Subscriber {
pub fn get_subscriber() eventbus.Subscriber[string] {
return *some_module.eb.subscriber
}