Is there particular pattern recommended for callin...
# multiplatform
j
Is there particular pattern recommended for calling Kotlin method from Swift where that method in turns
collects
values from some
flow
source (e.g. db)
1
right now I'm doing following (if you ignore fact that I probably shouldn't be using
GlobalScope
like this 🙂 )
Copy code
fun fetchPeople(success: (List<Assignment>) -> Unit) {
        GlobalScope.launch(Dispatchers.Main) {
            fetchPeopleAsFlow()?.collect {
                success(it)
            }
        }
    }
@Svyatoslav Scherbina now that we have capability to call suspend functions directly from Swift, is there anything similar planned for
flow
?
a
The KotlinConf app has a helper class CFlow that returns a Closeable so iOS can properly dispose of the job when it needs to... but otherwise it’s basically the same as this
j
k, thanks @ankushg, will take a look
👍 1