-
Notifications
You must be signed in to change notification settings - Fork 38
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
Feature [RM80] Character Repository #81
Conversation
The repository provides the original page of characters and each one after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking way better 💪 🎉
@@ -8,6 +8,19 @@ | |||
|
|||
import Foundation | |||
|
|||
|
|||
struct CharactersList: Decodable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Id probably update the naming here as it isnt a list. Maybe just CharactersResponse
is my usual go to for this kind of base level json response.
|
||
struct CharactersList: Decodable { | ||
let info: CharacterListInfo | ||
let results: [Character] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd utilise the CodingKeys enum here so you can give the property a better name like characters
. See Mapping different key names section
let results: [Character] | ||
} | ||
|
||
struct CharacterListInfo: Decodable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could then become CharacterResponseInfo
if you go with CharactersResponse
above
if let nextURLString = characterList.info.next { | ||
self.characterPageURL = URL(string: nextURLString)! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add another let
to this if let
to remove the ! in URL(string: nextURLString)!
if requestError != nil { | ||
DispatchQueue.main.async { | ||
error(requestError) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this here if its being done in the else on line 37? Also why is requestError not being checked for nil in that else?
protocol RickAndMortyServiceProtocol { | ||
func fetchData<T:Decodable>(url: URL, success: @escaping (T) -> (), error: @escaping (Error?) -> ()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
https://github.com/orgs/novoda/projects/1#card-66585869
Built a repository which provides each page of characters from the api.