Skip to content

Instantly share code, notes, and snippets.

@mathonsunday
Created May 7, 2021 19:39
Show Gist options
  • Save mathonsunday/dbbd186423c20b8f13ada866620d9bd2 to your computer and use it in GitHub Desktop.
Save mathonsunday/dbbd186423c20b8f13ada866620d9bd2 to your computer and use it in GitHub Desktop.
func suggest(query: String, currentLocation: Location? = nil) {
lastQuery = query
currentRequest?.cancel()
currentRequest = nil
let request = SearchSuggestRequestV2()
request.q = query
request.limit = 10
request.listingTypes = [.sales]
request.rankerVersion = "v4.0"
request.limitToGeos = []
request.includeAgentSearchableSuggestions = false
request.sources = [.address, .neighborhood]
request.categorizingStrategy = .classic
request.displayMode = .classic
currentRequest = omniSuggestService.omniSuggestAutoComplete(request: request, onNext: { [weak self] response, _ in
guard let self = self, query == self.lastQuery else {
return
}
self.suggestion = response
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment