Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class PopularMoviesPresenter(
private val getPopularMovies: GetPopularMovies,
coroutineContext: CoroutineContext = defaultDispatcher
) : BasePresenter<PopularMoviesView>(coroutineContext) {
override fun onViewAttached(view: PopularMoviesView) {
view.setLoadingVisible(true)
getPopularMovies()
}
private fun getPopularMovies() {
scope.launch {
getPopularMovies(
UseCase.None,
onSuccess = { view?.setPopularMovies(it.results) },
onFailure = { view?.showMoviesFailedToLoad() }
)
view?.setLoadingVisible(false)
}
}
}
interface PopularMoviesView {
fun setPopularMovies(movies: List<Movie>)
fun showMoviesFailedToLoad()
fun setLoadingVisible(visible: Boolean)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.