AddressAutocompleteController

class AddressAutocompleteController(debounceMillis: Long = 80, search: suspend (query: String, countryCode: String?) -> List<AddressSuggestion> = { query, country -> AddressSearchService.shared.suggest(query, country) }, retrieveAddress: suspend (AddressSuggestion) -> FrameObjects.BillingAddress? = { suggestion -> AddressSearchService.shared.retrieve(suggestion) })

Drives the suggestion list behind an address field.

Autocomplete never blocks manual entry. Every failure path — no token, Mapbox unreachable, an empty result set — clears the suggestions and reports nothing, so a user who is typing simply sees no list rather than an error.

Constructors

Link copied to clipboard
constructor(debounceMillis: Long = 80, search: suspend (query: String, countryCode: String?) -> List<AddressSuggestion> = { query, country -> AddressSearchService.shared.suggest(query, country) }, retrieveAddress: suspend (AddressSuggestion) -> FrameObjects.BillingAddress? = { suggestion -> AddressSearchService.shared.retrieve(suggestion) })

Types

Link copied to clipboard
object Companion

Tuning constants shared by every AddressAutocompleteController.

Properties

Link copied to clipboard

The current suggestion list. Empty while the field is unfocused, below MINIMUM_QUERY_LENGTH, or between keystrokes and a debounced search resolving.

Functions

Link copied to clipboard
fun clear()

Clears the list without sending anything, for dismissing on blur.

Link copied to clipboard
fun queryChanged(query: String, countryCode: String?)

Reacts to the user typing: waits out a short debounce, then searches.

Link copied to clipboard

Resolves a picked suggestion, or returns null when it cannot be resolved.