Igor Milakovic
02/09/2022, 10:04 PM// Shared.kt
@Throws(Exception::class)
suspend fun getSomething(param: SomeParam): Result<Something> {
// Some implementation.
}
// iosAppViewModel.swift
func getSomething(param: SomeParam) {
Shared().getSomething(param: param, completionHandler: { [weak self] result, error in
if let result = result {
// Do something with result.
} else if let error = error {
// Do something with error.
}
})
}
// androidAppViewModel.kt
fun getSomething(param: SomeParam) {
viewModelScope.launch {
kotlin.runCatching {
Shared().getSomething(param)
}.onSuccess { result ->
// Do something with result.
}.onFailure { error ->
// Do something with error.
}
}
}
Thank you!