Has anyone tackled the code generation for boilerp...
# multiplatform
m
Has anyone tackled the code generation for boilerplate between coroutines and Swift code? My plan is to use something similar to this https://dev.to/touchlab/working-with-kotlin-coroutines-and-rxswift-24fa to use coroutines/Flow as Swift Combine Publishers on the Swift side. But it requires a lot of boilerplate for a big project. Maybe there's a better alternative? I wanted to write a generic wrapper for the default completion blocks generated for
suspend
functions, but they don't have a stable signature, so I don't think it's possible.
j
Had also been thinking about something along these lines.....and also potentially addressing mapping to something that consumes Kotlin
Flow
m
This article that I pasted above also handles Flow. This is probably not the hardest part of the problem. Another thing to keep in mind is that we need explciit interfaces so that Swift has protocol on its side so that it can be faked in tests on the Swift side. I'm probaby gonna create some wireframe for the solution here and follow up in this thread.
j
fwiw I wrote short post about what I've been looking at so far for this https://johnoreilly.dev/posts/kotlinmultiplatform-swift-combine_publisher-flow/
the associated code has been pushed to https://github.com/joreilly/PeopleInSpace
very much early days right now but something hopefully that can be built on
m
thank you! will look into that
I'm close to having all the pieces of this codegen thing. In a few days or a week I should be able to post a rough preview on github. Seems to work pretty nice so far