Skip to content

Instantly share code, notes, and snippets.

@ericlewis
Created September 29, 2020 00:27
Show Gist options
  • Save ericlewis/1cbab5eb2a52b43f72f308d362bdd8d4 to your computer and use it in GitHub Desktop.
Save ericlewis/1cbab5eb2a52b43f72f308d362bdd8d4 to your computer and use it in GitHub Desktop.
lazy
extension DatabaseReference {
func observeSingleEventPublisher(of eventType: DataEventType) -> AnyPublisher<DataSnapshot, Error> {
Future<DataSnapshot, Error> { [weak self] completion in
self?.observeSingleEvent(of: eventType) {
completion(.success($0))
}
}
.eraseToAnyPublisher()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment