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

@@ -5,7 +5,7 @@ struct MyMessage {
}
fn test_fn_call_with_nonpointer_rvalue() {
eb := eventbus.new()
eb := eventbus.new[string]()
mut subscriber := eb.subscriber
subscriber.subscribe('my_publish', subscriber_method)
@@ -18,6 +18,6 @@ fn subscriber_method(receiver voidptr, ev &MyMessage, sender voidptr) {
println(ev)
}
fn do_something(eb &eventbus.EventBus) {
fn do_something[T](eb &eventbus.EventBus[T]) {
eb.publish('my_publish', eb, MyMessage{ msg: 'this is my message' })
}