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

refactor: completely revamp the API design for the Helix client #7

Merged
merged 8 commits into from
Feb 21, 2024

Conversation

LosFarmosCTL
Copy link
Owner

@LosFarmosCTL LosFarmosCTL commented Feb 21, 2024

Future requests will, instead of being called on the Helix instance itself, use HelixEndpoint objects with static factory methods for all the different endpoints, using generics to automatically infer return values:

// The old way
helix.doSomething(param1: "forsen")

// The new way
helix.request(endpoint: .doSomething(param1: "forsen"))

This allows the networking code to be separated properly from the code defining endpoints, therefore allowing different styles of network requests without having to write parts of them again for each endpoint.

// Completion Handlers
helix.requestTask(for: .doSomething(param1: "forsen")) { result, error in
}

// Async/Await
let result = try await helix.request(endpoint: .doSomething(param1: "forsen"))

// Combine
helix.requestPublisher(for: .doSomething(param1: "forsen")).sink(
  receiveCompletion: { error in

  },
  receiveValue: { result in

  })

@LosFarmosCTL LosFarmosCTL enabled auto-merge (squash) February 21, 2024 17:46
@LosFarmosCTL LosFarmosCTL merged commit 7376c3f into main Feb 21, 2024
4 checks passed
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.

1 participant