Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yimajo/7926de7a890867b429027da207869cb7 to your computer and use it in GitHub Desktop.
Save yimajo/7926de7a890867b429027da207869cb7 to your computer and use it in GitHub Desktop.
Wrap Firestore Remote Config's addOnConfigUpdateListener method for use with AsyncThrowingStream.
import Foundation
import FirebaseRemoteConfig
extension RemoteConfig {
func addOnConfigUpdateListener() -> AsyncThrowingStream<Set<String>, Error> {
.init { continuation in
addOnConfigUpdateListener { configUpdate, error in
if let error {
continuation.finish(throwing: error)
} else {
continuation.yield(configUpdate!.updatedKeys)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment