Skip to content

Commit

Permalink
Doc(@inquirer/search) Document recipe for debouncing search. Fixes #1490
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Jul 30, 2024
1 parent 3610c68 commit 306e847
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/search/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,26 @@ type Theme = {
- `always`: The help tips will always show and never hide.
- `never`: The help tips will never show.

## Recipes

### Debounce search

```js
import { setTimeout } from 'node:timers/promises';
import { search } from '@inquirer/prompts';

const answer = await search({
message: 'Select an npm package',
source: async (input, { signal }) => {
await setTimeout(300);
if (signal.aborted) return [];

// Do the search
fetch(...)
},
});
```

# License

Copyright (c) 2024 Simon Boudrias (twitter: [@vaxilart](https://twitter.com/Vaxilart))<br/>
Expand Down

0 comments on commit 306e847

Please sign in to comment.