-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
59 additions
and
67 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package nick.mirosh.newsapp.domain | ||
|
||
/** | ||
* Represents a result that can either contain successful data or an error. | ||
* | ||
*/ | ||
sealed class Result<out T> { | ||
/** | ||
* Represents successful data. | ||
* | ||
* @property data Data of generic type T. | ||
*/ | ||
data class Success<out T>(val data: T) : Result<T>() | ||
|
||
/** | ||
* Represents a failure. | ||
* | ||
* @property error The type of error, represented by ErrorType. | ||
*/ | ||
data class Error(val error: ErrorType) : Result<Nothing>() | ||
} |
8 changes: 4 additions & 4 deletions
8
app/src/main/java/nick/mirosh/newsapp/domain/feed/repository/NewsRepository.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
package nick.mirosh.newsapp.domain.feed.repository | ||
|
||
import nick.mirosh.newsapp.domain.Resource | ||
import nick.mirosh.newsapp.domain.Result | ||
import nick.mirosh.newsapp.domain.feed.model.Article | ||
|
||
interface NewsRepository { | ||
suspend fun getNewsArticles(): Resource<List<Article>> | ||
suspend fun getFavoriteArticles(): Resource<List<Article>> | ||
suspend fun updateArticle(article: Article): Resource<Article> | ||
suspend fun getNewsArticles(): Result<List<Article>> | ||
suspend fun getFavoriteArticles(): Result<List<Article>> | ||
suspend fun updateArticle(article: Article): Result<Article> | ||
} |
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
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
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
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
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
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
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