This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class BaseViewModel<UI_STATE : Parcelable, PARTIAL_UI_STATE, EVENT, INTENT>( | |
(...) | |
) : ViewModel(), | |
IntentDelegate<INTENT, PARTIAL_UI_STATE> by IntentDelegateImpl(), | |
InternalChangesDelegate<PARTIAL_UI_STATE> by InternalChangesDelegateImpl(), | |
EventDelegate<EVENT> by EventDelegateImpl() { | |
init { | |
viewModelScope.launch { | |
merge( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EventDelegateImpl<EVENT> : EventDelegate<EVENT> { | |
private val eventChannel = Channel<EVENT>(Channel.BUFFERED) | |
override fun getEvents(): Flow<EVENT> = eventChannel.receiveAsFlow() | |
override suspend fun setEvent(event: EVENT) { | |
eventChannel.send(event) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RocketsViewModelTest { | |
@JvmField | |
@RegisterExtension | |
val mainDispatcherExtension = MainDispatcherExtension() | |
@RelaxedMockK | |
private lateinit var getRocketsUseCase: GetRocketsUseCase | |
(...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[versions] | |
hilt = "2.50" | |
kotlin = "1.9.22" | |
kotlin-coroutines = "1.7.3" | |
retrofit = "2.9.0" | |
room = "2.6.1" | |
(...) | |
[plugins] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI workflow | |
on: pull_request | |
jobs: | |
build: | |
runs-on: macos-latest | |
timeout-minutes: 30 | |
steps: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const val ROCKET_DIVIDER_TEST_TAG = "rocketDividerTestTag" | |
@Composable | |
fun RocketsListContent( | |
rocketList: List<RocketDisplayable>, | |
(...) | |
) { | |
LazyColumn(...) { | |
itemsIndexed( | |
items = rocketList, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun refreshRockets(): Flow<PartialState> = flow<PartialState> { | |
refreshRocketsUseCase() | |
.onFailure { | |
emit(Error(it)) | |
} | |
}.onStart { | |
emit(Loading) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@HiltViewModel | |
class RocketsViewModel @Inject constructor( | |
(...) | |
private val refreshRocketsUseCase: RefreshRocketsUseCase, | |
(...) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun interface RefreshRocketsUseCase : suspend () -> Result<Unit> | |
suspend fun refreshRockets( | |
rocketRepository: RocketRepository, | |
): Result<Unit> = resultOf { | |
rocketRepository.refreshRockets() | |
} |
NewerOlder