Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin Flow - Replacement for callbackFlow

I am working on an Android project where MVVM is the architecture being used. There is a use case where a Flow in my Repository needs to be updated based on the results of a callback which is triggered when something in my Data Source changes. The most appropriate choice for this problem seems to be callbackFlow. However, it is still experimental. I am very tempted to use callbackFlow, however, I understand that any future changes might break some code and I don't want that to happen in a production app. Considering the above scenario, what should be a replacement for callbackFlow? Or should I consider going ahead with callbackFlow?

like image 394
Abdul Mateen Avatar asked Mar 01 '23 17:03

Abdul Mateen


1 Answers

callbackFlow is runtime stable - it works just as it is supposed to and it exists exactly because it is exactly the right tool to use in many cases.

I understand that any future changes might break some code and I don't want that to happen in a production app"

The only change that would affect how it functions is when upgrading your version of coroutines. That has nothing to do with runtime stability.

like image 146
ianhanniballake Avatar answered Mar 11 '23 13:03

ianhanniballake