Created
April 14, 2021 04:53
-
-
Save rohitjakhar/6575768fe4f02b830132a4ccd6949d7e to your computer and use it in GitHub Desktop.
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
package com.rohitjakhar.sagarkhurana.viewmodel | |
import androidx.lifecycle.ViewModel | |
import androidx.lifecycle.viewModelScope | |
import androidx.paging.Pager | |
import androidx.paging.PagingConfig | |
import androidx.paging.cachedIn | |
import com.google.firebase.auth.ktx.auth | |
import com.google.firebase.ktx.Firebase | |
import com.rohitjakhar.sagarkhurana.data.RemoteDataStore | |
import com.rohitjakhar.sagarkhurana.pagingdatasource.ProductFilterPaging | |
import com.rohitjakhar.sagarkhurana.pagingdatasource.ProductPagingSource | |
import com.rohitjakhar.sagarkhurana.utils.Constant.PRODUCT | |
class ProductViewModel : ViewModel() { | |
private val mobile = Firebase.auth.currentUser?.phoneNumber | |
private val db = | |
RemoteDataStore.firebaseUserCollection.document( "00").collection(PRODUCT) | |
private val dbFilter = | |
RemoteDataStore.firebaseUserCollection.document(mobile ?: "00").collection(PRODUCT) | |
.whereEqualTo("productId", "89427a4d-42e9-4da6-b735-27886c433225") | |
val fetechAllData = Pager(PagingConfig(20)) { | |
ProductPagingSource(db) | |
}.flow.cachedIn(viewModelScope) | |
val filterData = Pager(PagingConfig(20)) { | |
ProductFilterPaging(dbFilter) | |
}.flow.cachedIn(viewModelScope) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment