Skip to content

Instantly share code, notes, and snippets.

@enginebai
Created September 13, 2020 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enginebai/a21ec8e3da99eda3c5f0c772098542b0 to your computer and use it in GitHub Desktop.
Save enginebai/a21ec8e3da99eda3c5f0c772098542b0 to your computer and use it in GitHub Desktop.
MovieHunt blog part3. list data source factory
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