adjpd
02/11/2022, 11:04 PMsuspend
function as a constructor parameter. How can I call this in swift? I've attempted to pass a simple closure but it complains it doesn't conform to KotlinSuspendFunction0
. Any idea on the correct swift syntax? My attempt in 🧵.adjpd
02/11/2022, 11:05 PMclass Something(
val myfn: suspend () -> Unit
) {}
swift: (complains Argument type '()' does not conform to expected type 'KotlinSuspendFunction0'
)
Something(myfn: { })
adjpd
02/11/2022, 11:12 PMclass Hmm : KotlinSuspendFunction0 {
func invoke() async throws -> Any? {
print("hi?")
}
}
Something(myfn: Hmm())
hfhbd
02/12/2022, 10:14 AMadjpd
02/12/2022, 1:44 PMhfhbd
02/12/2022, 1:59 PMadjpd
02/12/2022, 2:00 PMhfhbd
02/12/2022, 2:02 PMrunBlocking
method to call async code in non-async block.
And Swift cancelation is not send to Kotlin suspend functions 😄adjpd
02/12/2022, 2:17 PMMainScope()
interaction. I thought I'd got around that by simply using suspend
methods instead. But now I'm getting the immutable coroutine exception again... Nice technology, but definitely alphaadjpd
02/12/2022, 2:24 PM