https://kotlinlang.org logo
Title
g

Giovanni Alluvatti

07/14/2020, 12:18 PM
Hello, does anybody know if ktor offer a feature similar to Spring Events Publisher. I mean, I know that you can subscribe to Ktor application events, but would be nice to know if I can throw my CustomEvent and having a custom listener that handle that event.
m

Matteo Mirk

07/14/2020, 12:43 PM
seems easy: https://ktor.io/advanced/events.html#subscribing-to-events-and-raising-them
If you want to create custom events and dispatch or raise them:
class MySubject
val MyEventDefinition = EventDefinition<MySubject>()
monitor.raise(MyEventDefinition, MySubject())
g

Giovanni Alluvatti

07/14/2020, 2:32 PM
thanks a lot! Totally missed that small part in the ktor docs.
👍 1
m

mp

07/15/2020, 4:42 PM
Guava also has a simple bus.
m

Matteo Mirk

07/16/2020, 9:12 AM
Why introduce a whole utility lib when Ktor already has this feature?