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

[#27] [Chore] Replace Alamofire with Moya #28

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

Shayokh144
Copy link
Collaborator

#27

What happened

Replace Alamofire networking library with Moya.

Insight

  • Remove Alamofire from pod
  • Add Moya in pod
  • Update networking code to integrate Moya

Proof Of Work

  • Features are working fine
Screen.Recording.2022-11-25.at.11.47.45.AM.mov
  • All tests are passed

Screenshot 2022-11-25 at 11 50 38 AM

Remarks

  • CI/CD won't run as Bitrise credit running out

@Shayokh144 Shayokh144 added this to the 0.2.0 milestone Nov 25, 2022
@Shayokh144 Shayokh144 self-assigned this Nov 25, 2022
@Shayokh144 Shayokh144 linked an issue Nov 25, 2022 that may be closed by this pull request
@Shayokh144 Shayokh144 force-pushed the chore/27-replace-alamofire-with-moya branch from e8406ab to eb20852 Compare November 25, 2022 05:07
@Shayokh144 Shayokh144 force-pushed the chore/27-replace-alamofire-with-moya branch from eb20852 to 516b39f Compare November 25, 2022 05:13
Copy link
Collaborator

@blyscuit blyscuit left a comment

Choose a reason for hiding this comment

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

Looks good, few comments.


var parameters: Parameters? { get }
enum RequestConfiguration {
case weather(cityName: String)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please include line break after enum {


var encoding: ParameterEncoding { get }
extension RequestConfiguration: TargetType {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this the on API? If we will have more endpoints I suggest creating a new file for each endpoint. TargetType+Weather.swift

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@blyscuit

  • After creating new file should I rename the enum RequestConfiguration to enum WeatherRequestConfiguration?
  • By I suggest creating a new file for each endpoint did you mean creating new file for each Target? like one Target can contain multiple cases with different paths/endpoints like here but one Target is for one baseUrl ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

  • I would say that it's easier to declare a new enum for each sub-service (similar APIs) because how enum in Swift works.
  • One Target enum can have multiple endpoints, divided by the business use case OR by the endpoints.

If we will only have one/two endpoints in this project then the refactor is not needed.


var headers: HTTPHeaders? { nil }
// Optional Stub
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please provide more descriptive comment, what is Optional Stub, do we have to do something about it in the future: TODO:.
I don't think we have to include sampleData in this declaration, correct me if I'm wrong.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you are right.. this sampleData is for creating mock response, will add details comment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same with comment with documentation.

According to the source code , this property is optional, so we don't have to declare it when using the default value.


var interceptor: RequestInterceptor? { nil }
// Optional Stub
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not optional since we declare some real value to it, I suggest removing this comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

By the comment I want to say that : these stubs can be skipped, actually I try to pretend like this is for iOS Template.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need to add comment as a documentation. When we use a library, the document is available on the library's repository. Adding library's comment in the project will lead to: - bloated code base & - need to revise comment if the library document changes.

We assume reader of this code knows Moya (because we pick Moya as part of the project) so we should not include the comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Chore] Replace Alamofire with Moya
2 participants