Skip to content

Instantly share code, notes, and snippets.

@LloydBlv
Created June 7, 2024 06:02
Show Gist options
  • Save LloydBlv/1e620c808c9eaf16800db356c0224c85 to your computer and use it in GitHub Desktop.
Save LloydBlv/1e620c808c9eaf16800db356c0224c85 to your computer and use it in GitHub Desktop.
class SearchViewModel‌ @Inject constructor(private val searchRepo: SearchRepository) : ViewModel() {
val searchResults: StateFlow<List<SearchResult>>
field = MutableStateFlow<List<SearchResult>>()
fun search(query: String) {
viewModelScope.launch {
val results = searchRepository.search(query)
searchResults.update { results }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment