There are lots of resources on how to use Flows from Swift. Is there any info on how to create Flows?
😱 1
h
hfhbd
10/17/2022, 12:34 PM
You want to implement the Kotlin flow interface in Swift? With all the callbacks and continuation objects and thread issues using the exported objective C API?
l
Lukáš Kúšik
10/17/2022, 12:36 PM
I have a domain interface that I would like to implement in Swift, which contains functions returning Flows.
h
hfhbd
10/17/2022, 12:37 PM
But you could still use some Kotlin functions to create the flow and call it from Swift.
l
Lukáš Kúšik
10/17/2022, 12:39 PM
I can't seem to find emptyFlow(), flowOf(), mutableStateOf(), functions in the exported shared module in Swift. I have created my own proxies for now, but I wonder if there's a different approach. Maybe a way to convert Combine to Flow?
But I would add some Kotlin helper methods that take some (suspend) lambda: () -> T and use it in a flow builder.
h
humblehacker
10/27/2022, 2:30 AM
@Lukáš Kúšik Have you had any luck getting this to work? I'd also like to implement a function returning a Flow in Swift.
l
Lukáš Kúšik
10/27/2022, 6:51 AM
@humblehacker I just create a MutableStateFlow that I update using setValue from a Combine sink, after exporting the coroutines library to the shared Cocoapod. Not exactly the correct solution but it's a Flow 🤷 😄