Skip to content

How to merge multiples repositories response in the use case #99

Open
@matiasdelbel

Description

@matiasdelbel

In the examples, I see that you are returning the repository result, without implementing any other operation against them. But it is common, that in an use case you have to query a repository and then operate again it result, maybe inserting the result into other repository. How do you handle this scenario?

interface OneRepository {
   fun operation(): Either<Error, Boolean>
}

interface OtherRepository {
   fun otherOperation() : Either<Error, Int>
}

class UseCase(val repository: OneRepository, val otherRepository: OtherRepository) {

   fun run(): Either<Error, String>() {
     val result = repository.operation()
     // TODO("If the result is success, then call the second repository, and if that result is also success return a success result")
    // TODO ("How we can handle the error for both repositories?")
   }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions