Skip to content

Commit

Permalink
refactor: xxStream postFix 붙이기, suspend 함수 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
murjune committed Sep 26, 2024
1 parent 590b2c6 commit aaaa367
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BattleViewModel(
val selectedState = _selectedState.asStateFlow()

val weatherPos: StateFlow<Int> = combine(
battleRepository.selectedWeatherStream(),
battleRepository.savedWeatherStream(),
weathers,
) { weather, weathers ->
if (weather == null || weathers.isEmpty()) return@combine null
Expand Down Expand Up @@ -103,12 +103,12 @@ class BattleViewModel(
private fun initSavedSelection() {
viewModelScope.launch {
launch {
battleRepository.savedPokemon().first()?.let {
battleRepository.savedPokemonStream().first()?.let {
updateOpponentPokemon(it.toSelectionUi())
}
}
launch {
battleRepository.savedPokemonWithSkill().first()?.let { (pokemon, skill) ->
battleRepository.savedPokemonWithSkillStream().first()?.let { (pokemon, skill) ->
updateMyPokemon(pokemon.toSelectionUi(), skill.toUi())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ interface BattleRepository {

suspend fun saveWeather(weatherId: String)

fun selectedWeatherStream(): Flow<Weather?>
fun savedWeatherStream(): Flow<Weather?>

suspend fun savedPokemon(): Flow<Pokemon?>
fun savedPokemonStream(): Flow<Pokemon?>

suspend fun savedPokemonWithSkill(): Flow<PokemonWithSkill?>
fun savedPokemonWithSkillStream(): Flow<PokemonWithSkill?>
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class DefaultBattleRepository(
skillId: String,
) = localBattleDataSource.savePokemonWithSkill(pokemonId, skillId)

override suspend fun savedPokemon(): Flow<Pokemon?> =
override fun savedPokemonStream(): Flow<Pokemon?> =
localBattleDataSource.pokemonId().map { it?.let { pokemonRepository.pokemon(it) } }

override suspend fun savedPokemonWithSkill(): Flow<PokemonWithSkill?> =
override fun savedPokemonWithSkillStream(): Flow<PokemonWithSkill?> =
localBattleDataSource.pokemonWithSkill().map {
it?.let { pokemonWithSkill ->
val pokemon = pokemonRepository.pokemon(pokemonWithSkill.pokemonId)
Expand All @@ -63,7 +63,7 @@ class DefaultBattleRepository(
override suspend fun saveWeather(weatherId: String) =
localBattleDataSource.saveWeather(weatherId)

override fun selectedWeatherStream(): Flow<Weather?> =
override fun savedWeatherStream(): Flow<Weather?> =
localBattleDataSource.weatherId().map {
if (it == null) {
return@map null
Expand Down

0 comments on commit aaaa367

Please sign in to comment.