https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
h

hansenji

11/30/2023, 11:05 PM
Is there a best practice for suspending functions in an interface that needs to be implemented on both iOS and Android using SKIE?
f

Filip Dolník

12/01/2023, 10:16 AM
Hi! I’m not sure if you can call this a best practice, but implementing suspend functions in Swift is possible; however there are some limitations. (These don’t apply to Android as SKIE doesn’t do anything there). The function that you need to implement is prefixed with “__” because the function you will call from elsewhere is an extension that cannot be overridden. This prefixed function is the original Kotlin function that you would use without SKIE. Therefore, it can use the “async/await” syntax, but it does not support the cancellation propagation. I don’t think there is a way around that unfortunately.
👍 1
h

hansenji

12/01/2023, 4:39 PM
Thanks
3 Views