Options
All
  • Public
  • Public/Protected
  • All
Menu

Representation of a search request passed as a parameter to a SearchProvider's onSearch listener function.

const provider = {
   name: "my-provider",
   title: "My Provider",
   onSearch: (request) => {
      const query = request.query;
      return getMyResults(query);
   }
};

Hierarchy

Index

Properties

Optional context

context: any

Additional custom context that can be used for searching.

id

id: string

The ID of the search request. Can be used to tie related search requests together between providers.

query

query: string

The search query.

Optional targets

targets: string[]

A list of search provider names to execute the search request against.

Methods

onClose

  • onClose(listener: () => void): void
  • Registers a listener that is called when the search request is closed by the search requester.

    Can be used to cleanup pending queries:

    async function onSearch(request) {
      const myQuery = makeQuery(request.query);
    
      request.onClose(() => {
         myQuery.cancel();
      });
    
      const results = await myQuery.getResults();
      return results;
    }
    

    Parameters

    • listener: () => void

      the listener to call when the request is closed.

        • (): void
        • Returns void

    Returns void

removeListener

  • removeListener(listener: () => void): void
  • Remove a registered listener.

    Parameters

    • listener: () => void

      the listener to remove.

        • (): void
        • Returns void

    Returns void

Legend

  • Property
  • Method

Generated using TypeDoc