Simon Buechner
10/09/2023, 7:00 AMRick Clephas
10/09/2023, 7:02 AMSimon Buechner
10/09/2023, 7:06 AMKMM Side
@NativeCoroutines
val discoveredDevicesFlow = session.discoveredDevicesFlow
iOS Side
// Create an AnyPublisher for your flow
let publisher = createPublisher(for: facade.discoveredDevicesFlow)
// Now use this publisher as you would any other
publisher.receive(on: mainQueue).sink { completion in
print("Received completion: \(completion)")
} receiveValue: { value in
self.discoveredDevices = value
}.store(in: &cancellables)
Rick Clephas
10/09/2023, 7:14 AMBluetoothDevice
data class? KMP-NativeCoroutines shouldn’t change the way the Flow value is represented.Simon Buechner
10/09/2023, 7:16 AMdata class BluetoothDevice(
val peripheral: BluetoothDevice,
var rssi: Int,
)
BluetoothDevice has a typealias for BluetoothDevice in android and CBPeripheral in iosRick Clephas
10/09/2023, 7:38 AMperipheral
property in Swift with type Any
?
(there is a limitation where Kotlin types implementing/inheriting ObjC types aren’t exposed to ObjC/Swift)Simon Buechner
10/09/2023, 7:40 AMRick Clephas
10/09/2023, 7:42 AMvalue
(in Swift) is just an array of `BluetoothDevice`s?Simon Buechner
10/09/2023, 7:42 AMRick Clephas
10/09/2023, 7:47 AM<<hole>>>
generics aren’t the same. What does the ForEach
code look like?Simon Buechner
10/09/2023, 7:50 AMdata class CustomDevice(
val peripheral: BluetoothDevice,
val identifier: String,
var rssi: Int,
)
needed the identifier.
List(viewModel.discoveredDevices, id: \.identifier){ device in
Button("device.rssi", action: viewModel.connect(device:device)
}
Text("\(digipen.rssi)")
.onTapGesture { viewModel.connect(device: device) }
Rick Clephas
10/09/2023, 8:01 AMi see it if i look into the fat frameworkIf that’s the case, it sounds more like a Swift issue than a Kotlin one.
Simon Buechner
10/09/2023, 8:09 AMRick Clephas
10/09/2023, 8:13 AMrssi
.Simon Buechner
10/09/2023, 8:51 AMRick Clephas
10/09/2023, 11:10 AM