https://kotlinlang.org logo
#getting-started
Title
# getting-started
l

Lokik Soni

08/06/2022, 3:45 PM
Inside batteryProfile flow I am collecting alertLevel flow. batteryProfile flow emit value when there is change in device battery using broadcast and alertLevel emit value when I change in seekbar in UI. What is happening in my case is that When I change the alertLevel using seek bar and currently there is no emission in the batteryProfile then it also calls lambda and the whole block of code is called again and again. But according to me it should update the level variable when there is another emission in batteryProfile.
Copy code
batteryProfile(Unit).flowWithLifecycle(lifecycle).collect { result ->
   val level = alertLevel(Unit).firstOrNull()?.data ?: Constants.DEF_VAL_LEVEL
   
}
2 Views