https://kotlinlang.org logo
Title
s

skneko

10/22/2018, 1:37 PM
Does Kotlin have any native way of working with an event driven architecture (like in C#, or Node.js EventEmitters)? I'm planning on making a library that, by definition, must be event driven and allow the user to define a set of handlers in response to the occurrence of a certain event. What would be the preferred way in Kotlin, or the best way according to your personal preferences? I'm thinking of defining an event class which has a list of handlers and then define a subscribe method to add the functions. I'm willing to implement this from scratch, but the main purpose of the library is not this one and I prefer to reuse an existing library if possible.
s

Shawn

10/22/2018, 1:41 PM
It sounds like you might want #rx (RxKotlin based on RxJava)?
Kotlin/JS exposes JavaScript Events, but I don’t think there’s a cross-platform analog, nothing quite exactly like C# has
Ilya authored this gist a little while back to show how you might implement it in Kotlin https://gist.github.com/orangy/11178911
s

skneko

10/22/2018, 1:44 PM
I do not plan to compile to JS so JS events don't really matter to me. I'm going to ask in #rx and check that gist. Thank you!
yes that gist is exactly what I need implemented
however it is very basic
I'm asking if there's any library that has all this figured out and complete already.