Created
September 13, 2020 23:14
-
-
Save enginebai/a21ec8e3da99eda3c5f0c772098542b0 to your computer and use it in GitHub Desktop.
MovieHunt blog part3. list data source factory
This file contains hidden or 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
class MovieListDataSourceFactory(private val category: MovieCategory): DataSource.Factory<Int, MovieModel>() { | |
val initLoadState = BehaviorSubject.createDefault(NetworkState.IDLE) | |
val loadMoreState = BehaviorSubject.createDefault(NetworkState.IDLE) | |
var dataSource: MovieListDataSource? = null | |
override fun create(): DataSource<Int, MovieModel> { | |
dataSource = MovieListDataSource(category, initLoadState, loadMoreState) | |
return dataSource!! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment