Skip to content

Commit

Permalink
refactor(PokemonListViewModel): 포켓몬 목록을 네트워크를 통해 가져온다
Browse files Browse the repository at this point in the history
  • Loading branch information
sh1mj1 committed Jul 23, 2024
1 parent b8c03ec commit 7813132
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ class PokemonListFragment :
private val viewModel by viewModels<PokemonListViewModel> {
PokemonListViewModel.factory(
pokemonListRepository =
DefaultPokemonListRepository(
pokemonListDataSource = RemotePokemonListDataSource(
pokeDexService = ServiceModule.pokeDexService(),
DefaultPokemonListRepository(
pokemonListDataSource =
RemotePokemonListDataSource(
pokeDexService = ServiceModule.pokeDexService(),
),
),
),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PokemonListViewModel(
.stateIn(
viewModelScope,
SharingStarted.WhileSubscribed(5000L),
pokemonListRepository.pokemons().map(Pokemon::toUi),
emptyList(),
)

private val _navigateToDetailEvent = MutableSharedFlow<Long>()
Expand All @@ -53,7 +53,7 @@ class PokemonListViewModel(
}
}

private fun queriedPokemons(query: String): List<PokemonUiModel> {
private suspend fun queriedPokemons(query: String): List<PokemonUiModel> {
if (query.isEmpty()) {
return pokemonListRepository.pokemons().map(Pokemon::toUi)
}
Expand Down

0 comments on commit 7813132

Please sign in to comment.