Open bendgk opened 1 year ago
I am interested in contributing Kotlin/Wasm (still in preview) support once you have made the library multiplatform and added Kotlin/JS support.
Maybe you could just make the lib fully multiplatform by using https://github.com/Kotlin/kotlinx-atomicfu.
Yeah sorry, this was on a backlog as I had real-life things to take care of, I'm gonna start working on porting over to Kotlin Multi-Platform today.
I'll take a look at atomicfu, and I believe you posted a blog post on Kotlin Multi-Platform somewhere, so I'll give that a read to :+1:
No problem, and thanks for taking care of that, feel free to share a branch or a PR if you want feedback. The blog post I published recently here is really focused on Kotlin/Wasm but yeah I would like to use effekt for frontend development with Kotlin/Wasm as a lightweight alternative to Compose.
Maybe you could just make the lib fully multiplatform by using https://github.com/Kotlin/kotlinx-atomicfu.
There is no need for that. Benjamin should use Mutex instead of ReantrantLock, and move to coroutines for concurrency
Mutex
implementation is leveraging atomicfu
, and I would like to avoid a mandatory dependency on Coroutines when not needed since on frontend footprint is super important, especially given the lighweight positioning of this library.
So I think I would advise:
kotlinx.coroutines.*
classes to concurrency/Concurrency.kt
atomicfu
in the library core (reactivity/Reactivity.kt
)Yeah, I possibly agree with this approach too. I originally really liked the lightweight approach and 0 dependencies that reactivity/Reactivity.kt had originally.
I think ill keep concurrency/Concurrent.kt though because Coroutine usage with EffeKt seems like a common valid use case.
Also, I'm not too sure how the decoupling of packages works in kotlin/gradle, would it be possible to include only either concurrency
or reactivity
and not both in a project? I think something like that would be ideal.
Could potentially be achieved by using compileOnly
for the Coroutines dependency, but I have not tried it on multiplatform projects.
Both Kotlin/JS and Kotlin/Wasm are using dead code elimination so this is potentially not strictly for the footprint goal, but it would be much cleaner to not pollute the classpath when Coroutines are not used by the user project, and avoiding the mandatory dependency also makes sense on JVM side.
Feature variants are another way to tackle that kind of need, but not sure we need this level of complexity, so if compileOnly
works on multiplatform project, I would stick to that.
Hum, I am AFK so have not tried but compileOnly
looks like JVM specific so, if confirmed, maybe for now keep the dependencies as they are, I will do footprint tests with Kotlin/JS and Kotlin/Wasm with your multiplatform implementation to check Coroutines classes are removed by the dead code elimination processing.
The key point as mentioned above is to not reference Coroutines classes or Concurrency.kt
from Reactivity.kt
.
You can make the dependency to kotlinx.coroutines not transitive.
dependencies {
implementation("anylib") {
transitive = false
}
}
Hey guys, just created the dev/multiplatform branch, come check it out!
I'm still working on adopting all the other discussions and recommendations that were passed around. Right now in dev/multiplatform the concurrency
package has been removed. I will work on bringing it back in with a new effektScope
API
Honestly, I love working on this project, but I may need to allocate my coding time for this project to the weekends for now (as real-life duty calls)
I did some test and it seems to work as expected on frontend with pretty low footprint, I did various refinements in https://github.com/sdeleuze/effekt/tree/dev/multiplatform feel free to integrate my additional commit.
Wasm support will require https://github.com/Kotlin/kotlinx-atomicfu/issues/278.
Worth to try the transitive = false
when you bring back the Coroutine support.
Since that's too early to provide Kotlin/Wasm support there, I have added support on KoWasm side via this commit and will leverage upstream effeKt when it will provide Wasm support (I guess Kotlin 1.8.20
final + Kotlin/Wasm support in atomicfu will be needed). I have added a DOM based sample if you want to have a look.
Thanks for the fork, Ill take a look at it in a bit.
Gonna work on the concurrency package later today and hopefully Tag an actual release with Multiplatform support
Kotlin supports cross-compilation to multiple platforms: native/js/jvm.
It would be cool if EffeKt was able to be targeted to be compiled as a Multiplatform project.