adjpd
02/13/2022, 9:03 PMStateFlow
that I'm collecting from swift. It works with a class that inherits from Kotlinx_coroutines_coreFlowCollector
. But it's rather ugly. Is there are more concise way? Code in 🧵class Collector<T> : Kotlinx_coroutines_coreFlowCollector {
let callback:(T) -> Void
init(callback: @escaping (T) -> Void) {
self.callback = callback
}
func emit(value: Any?) async throws -> KotlinUnit {
callback(value as! T)
return KotlinUnit()
}
}
repo.someStateFlow.collect(
collector: Collector<TheReturningData> { v in
print("result \(v)")
}
) { u, e in
print("finished")
}
hfhbd
02/13/2022, 9:10 PMJohn O'Reilly
02/13/2022, 9:16 PMadjpd
02/14/2022, 12:04 PM