launchdarkly / ios-client-sdk

LaunchDarkly Client-side SDK for iOS (Swift and Obj-C)
https://docs.launchdarkly.com/sdk/client-side/ios
Other
71 stars 85 forks source link

Add async await support in place of completion handlers #405

Open swhitty opened 3 months ago

swhitty commented 3 months ago

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:

The workarounds for these issues are non trivial.

galenqq commented 3 months ago

Would love to see this!

tanderson-ld commented 3 months ago

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