Hi, I have a KMP project that uses SKIE to map the...
# touchlab-tools
f
Hi, I have a KMP project that uses SKIE to map the Flows defined and used in classes from the shared module into Swift. In the shared module, I define interfaces that need to be implemented natively. A typical use case is defining an interface for a BLE service, where I want the implementation to be platform-specific. While everything works smoothly on Android, I’ve run into some limitations when using Flow on iOS. Let’s say we have the following interface:
Copy code
interface IBleService {
     val connectionState: Flow<ConnectionState>
     fun scan(): Flow<Device>
}
When implementing this interface in the iOS project, there’s currently no way to create a
SkieSwiftStateFlow
(or similar) that can be returned from the
connectionState
property and the
scan()
function. Just like on Android, it would be great to have a mechanism to create flows, something like
flow {}
or
channelFlow {}
, or even a proper constructor to instantiate them directly. The question is essentially related to this discussion: https://github.com/touchlab/SKIE/discussions/54, which unfortunately has not been followed up. Thank you.
s
Usually, the common code will provide the UI with flows to subsribe to, and hardly ever the UI will provide the common code with flows (the other way around). Is there a way to replace these Flows with a class that has a method that the iOS UI can call repeatedly instead?
f
Thank you for your reply. I didn’t fully understand your point. In our case, the interface is not meant to update the UI, but rather to provide a way to implement native business logic behaviors (like ble utils). We’re thinking about solving this by defining a shared service that implement the interface so that we can still use Flows. The shared service would then rely on native methods that respond to events using a delegation pattern.