Skip to main content

SuggestionProvider

Offers places that match text the person has only partly typed. It is a separate port from SearchProvider 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 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​

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​

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​

Source: packages/core/src/ports/suggestions.ts:27