Skip to content

Instantly share code, notes, and snippets.

@murattuzel
Created November 17, 2021 20:01
Show Gist options
  • Save murattuzel/18a9e7ba8de123ccd15d61604c5060ce to your computer and use it in GitHub Desktop.
Save murattuzel/18a9e7ba8de123ccd15d61604c5060ce to your computer and use it in GitHub Desktop.
class FetchMoviesUseCase(
private val dataSource: MovieRemoteDataSource
) {
suspend operator fun invoke(): Result<MoviesResponse> =
withContext(Dispatchers.IO) {
try {
Result.success(dataSource.fetchMovies())
} catch (exception: IOException) {
Result.failure(exception)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment