pguardiola
04/08/2022, 7:25 PMcommonMain
, do you know a simple example out there? i want to get rid off freeze
from iOS impl and understood that's not needed anymore starting with kotlin coroutines 1.6.0
my use case is simple i want to translate 👇 to use coroutines
common
internal expect fun Recorder.stop(result: (String?) -> Unit)
class Sandbox(private val recorder: Recorder) {
/**
* stop
*
* @param result
*/
fun stop(result: (String?) -> Unit) {
recorder.stop(result)
}
}
ios
internal actual fun Recorder.stop(result: (String?) -> Unit) {
val callback: IosSandboxCallback = {
result(it)
}
callback.freeze()
this.stopRecordingForResult(callback)
}
android
internal actual fun Recorder.stop(result: (String?) -> Unit) =
this.stopRecording { result(it) }
so basically suspend recorder.stop
until executes and then put the result back in main, anyone?