Skip to content

Instantly share code, notes, and snippets.

@zackshapiro
Created May 7, 2019 14:44
Show Gist options
  • Save zackshapiro/9287063e348e69d5d992136f5a03af41 to your computer and use it in GitHub Desktop.
Save zackshapiro/9287063e348e69d5d992136f5a03af41 to your computer and use it in GitHub Desktop.
// 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