KStateMachine / kstatemachine

KStateMachine is a powerful Kotlin Multiplatform library with clean DSL syntax for creating complex state machines and statecharts driven by Kotlin Coroutines.
https://kstatemachine.github.io/kstatemachine/
Boost Software License 1.0
358 stars 21 forks source link

Support wasmJs #94

Closed GuilhE closed 4 months ago

GuilhE commented 7 months ago

Any intention to support wasmJs target?

nsk90 commented 7 months ago

When I added multiplatoform support, I checked that it successfully compiles for JS target. But the second artefact (kstatemachine-coroutines) uses runBlocking function internally which is not supported on JS. So we can check that main artefact works easily. Just have to add JS target in gradle scripts. Then maybe it will be possible to cut unsupported api for JS from the second artefact.

Are you ready to try it? you can do it locally and open a PR. Alternatively I can try add JS target for main artefact myself, but I can check it only on compilation level.

GuilhE commented 7 months ago

I can try and give it a look in runtime, for now, I'm using Tinder's State Machine and since coroutines and atomic-fu already support wasmJs it was just a matter of updating the libraries (I've forked from a fork which originally added support for KMP). All tests passed, now I'm experimenting with a small POC to see what challenges I face.

GuilhE commented 7 months ago

Quick feedback, Tinder's State Machine with coroutines: 1.8.0 and atomic-fu: 0.23.2 it's working like a charm 👌🏼 I'll eventually open this POC to the community and share it where if you'll like 😉

nsk90 commented 7 months ago

So are you going to continue with KStateMachine?

GuilhE commented 7 months ago

Actually, I haven't been using KStateMachine because I've previously relied on Tinder's StateMachine for both Android and iOS, finding it quite intuitive. However, I've been conducting some market research to explore alternatives, given that Tinder's solution isn't receiving much attention. The upside is that it's lightweight and easy to integrate; it's essentially just a class that you can directly include in your project (since jitpack doesn't yet support KMP), so updating it to support iOS and Wasm was pratically just a matter of bumping versions. Nevertheless, moving forward, I'd prefer a solution that's actively maintained. In summary, while I'm not currently using KStateMachine, I'm open to giving it a try, especially once it becomes available for wasmJs, allowing for compatibility across Android, iOS, desktop, and wasm platforms.

nsk90 commented 4 months ago

Wasm support added in https://github.com/KStateMachine/kstatemachine/releases/tag/v0.30.0 release