Skip to content

Instantly share code, notes, and snippets.

@mortenbekditlevsen
Last active July 26, 2018 12:15
Show Gist options
  • Save mortenbekditlevsen/0b0f5730a623281cecf3fc6674d9bb60 to your computer and use it in GitHub Desktop.
Save mortenbekditlevsen/0b0f5730a623281cecf3fc6674d9bb60 to your computer and use it in GitHub Desktop.
public extension DatabaseQuery {
func observeSingleEvent<T>(of type: DataEventType,
with block: @escaping (DecodeResult<T>) -> Void)
where T: Decodable {
observeSingleEvent(of: type) { snap in
block(snap.decoded())
}
}
func observe<T>(eventType: DataEventType,
with block: @escaping (DecodeResult<T>) -> Void) -> UInt
where T: Decodable {
return observe(eventType, with: { snap in
block(snap.decoded())
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment