KStateMachine / kstatemachine

KStateMachine is a Kotlin DSL library for creating state machines and statecharts.
https://kstatemachine.github.io/kstatemachine/
Boost Software License 1.0
339 stars 19 forks source link

Built-in coroutines support #50

Closed nsk90 closed 1 year ago

nsk90 commented 1 year ago

This will add possibility to run suspending code in blocking way (with launch()) from machine listeners.

WeberHsu commented 1 year ago

When can finish it enhancement ? It's common use case in our development... Thanks

nsk90 commented 1 year ago

Can't say now. I'll pay it more attention, if you need this feature. You can write here your expectations.

From my point of view the most important here is making listener callback functions suspendable. Currently I don't know the way how to implement it. As I don't want to add coroutines as dependency to main library .jar, keeping it separate in additional coroutines support .jar.

WeberHsu commented 1 year ago

I expect that it can be supported coroutines and I can use suspend function when transition between states, it is normal use cases in implementation if you used coroutine in your project....

nsk90 commented 1 year ago

I have added basic coroutines support in v0.20.0. now working on publishing it maven central. ferther improvments for coroutines integration will be done in next versions.

Note that you should also use new 'kstatemachine-coroutines' artifact to work with coroutines.