ios-client-sdk
ios-client-sdk copied to clipboard
Add async await support in place of completion handlers
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.
Would love to see this!
Thank you for the feedback! We will take it into consideration.
Another argument for true async-await support in the LD SDK, right now, activating the Swift 6 compile mode actually breaks the LD SDK.
Any news on this one? Is it on the roadmap?
We have tentative plans that will address this and is on our radar.