Сбор потока Kotlin MongoDB Realm не может передать параметр в запрос ⇐ Android
-
Anonymous
Сбор потока Kotlin MongoDB Realm не может передать параметр в запрос
I'm in stuck.
I have Realm database. In viewmodel I receive data as a flow. In Fragment collect it.
Problem is when i want to filter / pass a param to realm query - there is no changes.
Viewmodel code:
class StateAppModel : ViewModel() { val savedBooks: StateFlow = repository.allBooksAsFlowable(SearchDiaryFilters(searchDiaryText.value)) .stateIn(viewModelScope, SharingStarted.Eagerly, emptyList()) } Database:
fun allBooksAsFlowable(searchDiaryFilters: SearchDiaryFilters? = null): Flow { return realm.query().sort("created", Sort.DESCENDING).asFlow().map { it.list } } Fragment:
lifecycleScope.launch { viewModel.savedBooks.collect { booksAdapter.submitData(it) } } I dont't understand how to pass filter string, e.g. on EditText text change.
Thanks in advance!
Источник: https://stackoverflow.com/questions/780 ... m-to-query
I'm in stuck.
I have Realm database. In viewmodel I receive data as a flow. In Fragment collect it.
Problem is when i want to filter / pass a param to realm query - there is no changes.
Viewmodel code:
class StateAppModel : ViewModel() { val savedBooks: StateFlow = repository.allBooksAsFlowable(SearchDiaryFilters(searchDiaryText.value)) .stateIn(viewModelScope, SharingStarted.Eagerly, emptyList()) } Database:
fun allBooksAsFlowable(searchDiaryFilters: SearchDiaryFilters? = null): Flow { return realm.query().sort("created", Sort.DESCENDING).asFlow().map { it.list } } Fragment:
lifecycleScope.launch { viewModel.savedBooks.collect { booksAdapter.submitData(it) } } I dont't understand how to pass filter string, e.g. on EditText text change.
Thanks in advance!
Источник: https://stackoverflow.com/questions/780 ... m-to-query
Мобильная версия