Skip to content

Instantly share code, notes, and snippets.

@paulmars
Created August 17, 2017 18:21
Show Gist options
  • Save paulmars/b171fd92ba28e0f347cd646f7cc44a40 to your computer and use it in GitHub Desktop.
Save paulmars/b171fd92ba28e0f347cd646f7cc44a40 to your computer and use it in GitHub Desktop.
Search once rate limit
let seconds:TimeInterval = 1.0
var lastSearched: Date?
func searchName() -> Void {
guard (self.lastSearched == nil) || self.lastSearched! < Date() else {
return
}
self.lastSearched = Date(timeIntervalSinceNow: seconds)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment