Jérémy CROS
11/10/2025, 3:59 PMclass Provider {
private val listener by lazy {
object: 3rdPartyListener {
// Bunch of callbacks
// The one I actually care about
override fun onError() {
// Spam errors when in errors, do nothing otherwise
}
}
}
}
I've read about callbackFlow but I can't quite make it work.
For the use case of a callback that spam error / do nothing, AI is suggesting using a debounce but I don't know, that seems weird...
Any help / suggestions appreciated! 🙏Tgo1014
11/10/2025, 4:09 PMcallbackFlow should be what you need. What did you try with it?David Kurzica
11/12/2025, 1:41 PMclass Provider {
private val listenerFlow = callbackFlow {
object: 3rdPartyListener {
// Bunch of callbacks
// The one I actually care about
override fun onError(e: Error) {
// Spam errors when in errors, do nothing otherwise
// Emit the error to the flow
trySend(e)
}
}
}
}Jérémy CROS
11/13/2025, 10:38 AMLukasz Kalnik
11/13/2025, 2:25 PMLukasz Kalnik
11/13/2025, 2:27 PMwithTimeoutOrNull() and if there were no "onError" events then emit some other UiState.
Modularize the solution, don't try to put everything into the callbackFlow.
Did I get your question right?