Created
March 28, 2021 22:42
-
-
Save rohitjakhar/b735424f1cd406febe92fc722fc9ce03 to your computer and use it in GitHub Desktop.
ViewModel
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.blogx.ui.home | |
import androidx.lifecycle.ViewModel | |
import androidx.lifecycle.viewModelScope | |
import androidx.paging.Pager | |
import androidx.paging.PagingConfig | |
import androidx.paging.cachedIn | |
import com.rohitjakhar.blogx.model.PostData | |
import com.rohitjakhar.blogx.network.ApiService | |
import com.rohitjakhar.blogx.repository.PostDataSource | |
import com.rohitjakhar.blogx.repository.remote.RemoteDataSource | |
class HomeViewModel() : ViewModel() { | |
private val remoteData = RemoteDataSource | |
val listData = Pager(PagingConfig(pageSize = 10)) { | |
PostDataSource(remoteData) | |
}.flow.cachedIn(viewModelScope) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment