The class ErrorsUtil is used to compare errors for classes that conform to Equatable. (1) That's hacky to compare Error for equatable, (2) it's not up to us to conform Error to Equatable and (3) I don't trust it. When using a hack, it gives you an opportunity to step back and ask if you can do something better.
Tasks:
To the end user they may not notice much. We may change the API to whenCache {} and whenNoCache {} where the errors do not exist in there and instead move that logic into the result returned from the Observable. We could change OnlineRepository.observe() to return a tuple, a new struct, or a Result<> type instead that houses an error.
This will remove some hackiness from the library, make the API easier to work with when observing the cache.
The class
ErrorsUtilis used to compare errors for classes that conform toEquatable. (1) That's hacky to compare Error for equatable, (2) it's not up to us to conform Error to Equatable and (3) I don't trust it. When using a hack, it gives you an opportunity to step back and ask if you can do something better.Tasks:
ErrorfromOnlineDataStateandLocalDataState. These structs exist to contain the state of the data, not the state of the refresh. By removing theErrorfrom these objects, it will make these structs be closer to their purpose, make the code more simple and allow us to fix this issue.To the end user they may not notice much. We may change the API to
whenCache {}andwhenNoCache {}where the errors do not exist in there and instead move that logic into the result returned from the Observable. We could change OnlineRepository.observe() to return a tuple, a new struct, or a Result<> type instead that houses an error.This will remove some hackiness from the library, make the API easier to work with when observing the cache.