Created
August 17, 2017 18:21
-
-
Save paulmars/b171fd92ba28e0f347cd646f7cc44a40 to your computer and use it in GitHub Desktop.
Search once rate limit
This file contains hidden or 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
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