I'm just getting started with kotlin so I don't really want to implement my own at this stage. I like the api of this project and it's well tested but has some dependencies on Java that I'm not quite sure how to resolve (particularly references to Class and Generics)
https://github.com/MiloszKrajewski/stateful4k
k
karelpeeters
03/18/2018, 5:23 PM
Perhaps you could contact the dev and ask to make the libeary available for multiplatform projects?
It doesn't look like it has any JVM-only dependencies, except for junit but that's handled by
kotlin.test
.
d
damian
03/18/2018, 6:40 PM
Thanks, yeah I did that via submitting an issue to the project. There are dependencies in a few places e.g. usage of java.util.*, @JvmStatic annotations and some generics using java.lang.Class that I'm not yet sure how I would model in Kotlin
k
karelpeeters
03/18/2018, 6:41 PM
Kotlin has
KClass
, so that shouldn't be a problem I think? Good luck!
👍 1
o
orangy
03/19/2018, 6:45 AM
Or may be use coroutines which are essentially compiled to state machines
l
louiscad
03/19/2018, 5:27 PM
For state machines, there are a two matches depending on your needs. enums for simple ones. sealed classes that can be nested and include companion objects for more complex ones.
Also, maybe coroutines which don't expose a state machine, but are based on one generated at compilation are just what you need