# SuggestionProvider

Offers places that match text the person has only partly typed. It is a
separate port from [`SearchProvider`](https://docs.mapcairn.com/api/core/SearchProvider.md) because the two have different
usage terms: a service that suits a submitted search often forbids a request
on every keystroke, and one built for typing seldom promises the same data.
Each suggestion is a full [`SearchResult`](https://docs.mapcairn.com/api/core/SearchResult.md) with a centre and an
optional extent, so picking one needs no second lookup.

This is an interface exported by `@mapcairn/core`, checked against version 0.2.0.

## Signature

```ts
import type { SuggestionProvider } from "@mapcairn/core";
 
interface SuggestionProvider
```

## Description

Implementations throw `SearchError` for offline, rate-limited, timed-out or
failed requests and `PortAbortError` when the signal fires. When to ask
(debounce, a minimum length), cancelling a superseded request and backing
off after repeated failures belong to one ui hook. A service's own usage
limits belong to its implementation, since every caller shares them.

## Methods

### suggest

```ts
suggest(query: string, options?: SuggestOptions): Promise<readonly SearchResult[]>;
```

Offers places that match the text typed so far. A blank query resolves to an empty list.

- `query` (`string`)
- `options?` (`SuggestOptions`)

## See also

- [`SuggestOptions`](https://docs.mapcairn.com/api/core/SuggestOptions.md)
- [`SearchResult`](https://docs.mapcairn.com/api/core/SearchResult.md)

Source: [packages/core/src/ports/suggestions.ts:27](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/ports/suggestions.ts#L27)
