Created
May 7, 2019 14:44
-
-
Save zackshapiro/9287063e348e69d5d992136f5a03af41 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
// Check if we have a certain user in our cache | |
if let user = db.query("SELECT FROM users WHERE id = \(id)").first { | |
callback(user) | |
} | |
else { | |
// Fetch from the network instead | |
API.request("/users?id=\(id)").onSuccess { response in | |
callback(response.user) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment