-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change class ResponseResult to Response
- Loading branch information
Souleymane Sidibe
committed
Aug 13, 2021
1 parent
31baca8
commit 8dbd558
Showing
14 changed files
with
51 additions
and
53 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 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
8 changes: 4 additions & 4 deletions
8
app/src/main/java/com/soulesidibe/todoapp/viewmodel/extensions.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
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
5 changes: 2 additions & 3 deletions
5
domain/src/main/java/com/soulesidibe/domain/GetTodosUseCase.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,13 +1,12 @@ | ||
package com.soulesidibe.domain | ||
|
||
import com.soulesidibe.domain.entity.TodoEntity | ||
import com.soulesidibe.domain.exception.NoTodosFoundException | ||
import com.soulesidibe.domain.repository.TodoRepository | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
class GetTodosUseCase(private val repository: TodoRepository) : | ||
UseCaseFlow<None, Flow<ResponseResult<List<TodoEntity>>>> { | ||
override suspend fun execute(param: None): Flow<ResponseResult<List<TodoEntity>>> { | ||
UseCaseFlow<None, Flow<Response<List<TodoEntity>>>> { | ||
override suspend fun execute(param: None): Flow<Response<List<TodoEntity>>> { | ||
return repository.get() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.soulesidibe.domain | ||
|
||
sealed class Response<T> { | ||
data class Success<T>(val data: T) : Response<T>() | ||
data class Error<T>(val throwable: Throwable) : Response<T>() | ||
|
||
companion object { | ||
fun <T> success(data: T) = Success(data) | ||
fun <T> failure(throwable: Throwable) = Error<T>(throwable) | ||
} | ||
} | ||
|
||
|
||
inline fun <R, T> Response<T>.map(transform: (value: T) -> R): Response<R> { | ||
return when(this) { | ||
is Response.Error -> Response.failure(this.throwable) | ||
is Response.Success -> Response.success(transform(this.data)) | ||
} | ||
} |
19 changes: 0 additions & 19 deletions
19
domain/src/main/java/com/soulesidibe/domain/ResponseResult.kt
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
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