Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPA-90_refactor-kotlin-result-to-request-result #11

Open
wants to merge 10 commits into
base: MPA-78_create-new-event
Choose a base branch
from

Conversation

andresantos252
Copy link
Collaborator

This PR changes the return type of the repositories from Kotlin Result to RequestResult, which is equivalent to the former, and allows Swift code to access the Result value or error.

class EventRepository(private val apiClient: IEventApiClient) : IEventRepository {
override suspend fun getAllEventsForUser(userId: String): Result<List<EventDTO>> {
return apiClient.getAllEventsForUser(userId)
override suspend fun getAllEventsForUser(userId: String): RequestResult<List<EventDTO>> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vão ter camada de domínio no projeto? Se sim, não faz muito sentido um repositório, que é suposto devolver domain models, devolver um RequestResult. O domínio é agnóstico à origem dos dados.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A ideia era facilitar a passagem de erros para as camadas que chamam os repo

@@ -43,8 +49,8 @@ class EventRepository(private val apiClient: IEventApiClient) : IEventRepository
includesBreakfast: Boolean?,
city: String?,
project: ProjectDTO?
): Result<Nothing?> {
): RequestResult<Nothing?> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isto não te vai rebentar sempre que chamares o método? Se queres devolver "nada" usa Unit. O Nothing dá trigger a excepções se bem me lembro.

Copy link

@rcosteira79 rcosteira79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mudar o Nothing para Unit

Base automatically changed from MPA-73_Get-projects to MPA-78_create-new-event May 11, 2023 12:55
…A-90_refactor-kotlin-result-to-request-result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants