Skip to main content

All Questions

0 votes
1 answer
2k views

The communication between: A view, A viewModel, A useCase, A repository, A service, and A dao in a clean architecture (MVVM) for Android

Using the monarchy realm database, a dao gives liveData. A repository gives that liveData to a useCase as a flow using .asFlow on the liveData. The useCase needs to return the flow to a ViewModel ...
Sagar Patel's user avatar
0 votes
1 answer
2k views

How to test the ViewModel using Junit, Mockito and Kotlin flows in Android

I tried to test the ViewModel using Junit and Mockito, getting null pointer exception. It returns cannot invoke flow collector. I want to test the responses coming in MpinDataKey, check all parameters ...
Cijo K Paul's user avatar
0 votes
1 answer
2k views

How to get value from ViewModel viewModelScope.launch without observing it in Activity?

I am in the process to re-build my live app to use MVVM and Coroutines and moving most of the code that is not UI related from Activity/Fragment to ViewModel. Currently, my app uses Java language for ...
DevPeter's user avatar
0 votes
1 answer
94 views

Fill ExposedDropdownMenu with data from other feature?

I am new to Android Development and I am just trying to build my first app. After watching several videos on YouTube and reading a lot of articles in the internet I have a first version of my ...
Franklin's user avatar
1 vote
1 answer
814 views

Combine data from Kotlin Flow/LiveData

I've got a flow from my repository that looks something like this: val userListFlow: Flow<List<User>> = channelFlow<List<User>> { source.setOnUserUpdatedListener { ...
Matt Wolfe's user avatar
  • 9,254
1 vote
1 answer
2k views

Android. Kotlin Flow: How to cancel countdown timer?

I have a kotlin flow timer. Here is my code: class CountDownTimer { suspend fun startTimer(value: Int, onTick: OnTickCallback, onFinish: OnFinishCallback) { onTick.invoke(0) (1..timerValue)...
testivanivan's user avatar
  • 1,494
1 vote
0 answers
228 views

How to get continuous updates of firebase `childEventListener` from `repository` to `viewModel` using `flow`?

view observes liveData from viewModel, viewModel calls firebase childEventListener api to get updates from repository, repository is using flow, How to send updates from repository to viewModel How ...
Sagar Patel's user avatar
1 vote
2 answers
10k views

Build a list from kotlin flow

I'm trying to build an application that use kotlin flows from the data layer up to the view but struggle so much with simple problems like this one. I'm collecting integer values from a StateFlow ...
Bencri's user avatar
  • 1,273
1 vote
0 answers
1k views

Kotlin-flow: Suspension functions can be called only within coroutine body

I'm trying to understand how Kotlin Flow works with coroutines and I decided to work on a test app. I'm using an MVVM + clean architecture. Here's a snippet of my data layer class ...
Claude Hangui's user avatar
2 votes
0 answers
549 views

Testing Flow with MVVM result NullPointerException

I am trying to test the return value of a ViewModel method. When the method is called, a usecase is executed and return a flow. Then the method return a liveData from the flow: The viewmodel: class ...
esteban's user avatar
  • 563