Questions tagged [kotlin-sharedflow]

52 questions
0
votes
1 answer

Flow Debounce for several types

I have a screen with several switchcompats like on photo. And I want to collect only last input of each of them to send it to server. I use SharedFlow. Now I take last state by debounce but it returns only one for all the toggles. How can I use…
apomytkina
  • 19
  • 1
  • 6
0
votes
2 answers

Kotlin Coroutine Flow: Limit the number of collector

Is there a way to limit the number of collector in a function that returns a Flow using flow builder? I have this public method in a ViewModel fun fetchAssets(limit: String) { viewModelScope.launch { …
0
votes
0 answers

Interleave a shared flow and non-blocking channel in Kotlin at specific points

I have a SharedFlow and I want to interleave items from the non-blocking channel in a specific frequency. (input / hot) Flow -> A, B, C, D, E, F, G, H, I, ... Channel -> 1, 2, 3, 4, 5, ... Output flow -> A, B, C, 1, D, E, F, 2, G, H, I, 3, ... (if…
rysv
  • 2,416
  • 7
  • 30
  • 48
0
votes
1 answer

How do I get previous value from SharedFlow after Activity recreate/Configuration change in Jetpack Compose?

Suppose I have ScanActivity using jetpack compose that can scan Barcode, the result will shown in TextField and result will survive from configuration change(e.g screen rotation). I won't use StateFlow because after the result shown then I rotate my…
0
votes
1 answer

SharedFlow won't emit value to subscriber at fragment (collect)

I want to use SharedFlow instead of StateFlow because first one doesn't require initial value ViewModel: val photosPaginData = photoRepository.getPhotosPagingData() // Flow> .cachedIn(viewModelScope) …
0
votes
1 answer

How to Avoid Race Condition in FragmentManager?

My goal is to allow only one single instance of the same dialog fragment in the fragment stack. The current trigger condition is coming from a SharedFlow and can be triggered as often as 7ms apart between values. Here's what I have tried: Placing…
0
votes
1 answer

Best practise for replacing current coroutine call in viewmodels

I have the following: interface CartRepository { fun getCart(): Flow } interface ProductRepository { fun getProductByEan(ean: String): Flow> } class ScanViewModel( private val productRepository:…
nilsi
  • 10,351
  • 10
  • 67
  • 79
1 2 3
4