Last active
July 26, 2018 12:15
-
-
Save mortenbekditlevsen/0b0f5730a623281cecf3fc6674d9bb60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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