Closed GustavoSanMartin closed 5 years ago
For the most part, we won't need flow { }
blocks and will instead mostly use ConflatedBroadcastChannel
instead. Each type of search result will have its own ConflatedBroadcastChannel
that can offer items individually from each other. These channels will be converted and "merged" into a single flow in the GetSearchResultsUseCase
which can then be consumed by the ViewModel.
The general data flow:
ViewModel -> UpdateQueryUseCase -> SearchRepository -> DB/Network -> Broadcast Results -> CombineLatest in GetSearchResultsUseCase -> ViewModel
You can also add an UpdateQueryUseCase
to handle updating the current search. The viewmodel shouldn't have a direct reference to the repository.
Merging #56 into master will increase coverage by
4.04%
. The diff coverage is43.85%
.
@@ Coverage Diff @@
## master #56 +/- ##
==========================================
+ Coverage 8.81% 12.86% +4.04%
==========================================
Files 57 60 +3
Lines 635 653 +18
Branches 82 95 +13
==========================================
+ Hits 56 84 +28
+ Misses 569 543 -26
- Partials 10 26 +16
Impacted Files | Coverage Δ | |
---|---|---|
.../java/ca/llamabagel/transpo/di/GeocodingWrapper.kt | 0% <0%> (ø) |
|
...c/main/java/ca/llamabagel/transpo/di/CoreModule.kt | 0% <0%> (ø) |
:arrow_up: |
.../ca/llamabagel/transpo/ui/search/SearchActivity.kt | 0% <0%> (ø) |
:arrow_up: |
...bagel/transpo/ui/search/GetSearchResultsUseCase.kt | 100% <100%> (ø) |
|
...llamabagel/transpo/ui/search/UpdateQueryUseCase.kt | 100% <100%> (ø) |
|
...ava/ca/llamabagel/transpo/data/SearchRepository.kt | 50% <51.72%> (+50%) |
:arrow_up: |
...ca/llamabagel/transpo/ui/search/SearchViewModel.kt | 75% <62.5%> (ø) |
:arrow_up: |
... and 1 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 13d50c5...c985f4d. Read the comment docs.
Any usage of `when`
can be replaced with whenever
.
Use a TestCoroutineDispatcher
instead of "mainThreadSurrogate
". This fixes all of the tests.
I still recommend using fakes for UseCase/Repository/Data Source levels instead of mocking because the actual logic of those classes can be tested rather than just verifying that methods are called.
Doesn't work. Just copied what @dellisd did.