Skip to content

Commit 81b89b9

Browse files
Remove code for flow exercise about 'Intermediate operators'
1 parent 0585908 commit 81b89b9

File tree

1 file changed

+1
-47
lines changed

1 file changed

+1
-47
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package com.lukaslechner.coroutineusecasesonandroid.usecases.flow.usecase2
22

33
import androidx.lifecycle.LiveData
4-
import androidx.lifecycle.asLiveData
54
import com.lukaslechner.coroutineusecasesonandroid.base.BaseViewModel
65
import kotlinx.coroutines.CoroutineDispatcher
7-
import kotlinx.coroutines.flow.*
8-
import timber.log.Timber
96

107
class FlowUseCase2ViewModel(
118
stockPriceDataSource: StockPriceDataSource,
@@ -26,48 +23,5 @@ class FlowUseCase2ViewModel(
2623
2724
*/
2825

29-
val currentStockPriceAsLiveData: LiveData<UiState> = stockPriceDataSource
30-
.latestStockList
31-
.withIndex()
32-
.onEach { indexedValue ->
33-
Timber.d("Processing emission ${indexedValue.index + 1}")
34-
}
35-
.map { indexedValue ->
36-
indexedValue.value
37-
}
38-
.take(10)
39-
.filter { stockList ->
40-
val googlePrice = stockList.find { stock ->
41-
stock.name == "Alphabet (Google)"
42-
}?.currentPrice ?: return@filter false
43-
44-
googlePrice > 2300
45-
}
46-
.map { stockList ->
47-
stockList.filter { stock ->
48-
stock.country == "United States"
49-
}
50-
}
51-
.map { stockList ->
52-
stockList.filter { stock ->
53-
stock.name != "Apple" && stock.name != "Microsoft"
54-
}
55-
}
56-
.map { stockList ->
57-
stockList.mapIndexed { index, stock ->
58-
stock.copy(rank = index + 1)
59-
}
60-
}
61-
.map { stockList ->
62-
stockList.filter { stock ->
63-
stock.rank <= 10
64-
}
65-
}
66-
.map { stockList ->
67-
UiState.Success(stockList) as UiState
68-
}
69-
.onStart {
70-
emit(UiState.Loading)
71-
}
72-
.asLiveData(defaultDispatcher)
26+
val currentStockPriceAsLiveData: LiveData<UiState> = TODO()
7327
}

0 commit comments

Comments
 (0)