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

Add async await support in place of completion handlers #405

Open
swhitty opened this issue Aug 8, 2024 · 2 comments
Open

Add async await support in place of completion handlers #405

swhitty opened this issue Aug 8, 2024 · 2 comments

Comments

@swhitty
Copy link

swhitty commented Aug 8, 2024

Is your feature request related to a problem? Please describe.
The current Swift API is lacking support for async / await. While developers can naively wrap the existing methods with continuations ignoring cancellation, native support for async / await with support for cancellation would be preferred.

Describe the solution you'd like
Key APIs that currently include completion handlers also offer an async await extension

public extension LDClient {

  static func start(config: LDConfig, startWaitSeconds: TimeInterval) async throws { .. }

  func setOnline(_ goOnline: Bool) async throws { .. }
  
  func identify(context: LDContext) async throws { .. }
  
}

Describe alternatives you've considered
I currently write these extension myself but there are a few issues due to limitations within the public API:

  • start() can call its completion handler multiple times if timeout expires before it becomes online.
  • start(), setOnline() & identifiy() have no API to cancel causing completion handler to receive failure. e.g. URLSessionTask.cancel()

The workarounds for these issues are non trivial.

@galenqq
Copy link

galenqq commented Aug 8, 2024

Would love to see this!

@tanderson-ld
Copy link
Contributor

Thank you for the feedback! We will take it into consideration.

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

No branches or pull requests

3 participants