Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024-03-30-debouce #1142

Merged
merged 3 commits into from
Apr 3, 2024
Merged

2024-03-30-debouce #1142

merged 3 commits into from
Apr 3, 2024

Conversation

ealush
Copy link
Owner

@ealush ealush commented Apr 1, 2024

| Related issues | #1057 1057 |

debounce()

The debounce() function in Vest helps you optimize function execution by introducing a delay. This is useful in scenarios where a function is called repeatedly due to user interaction, and you only want to execute the latest version after a period of inactivity.

Usage

1. Import Debounce

import debounce from 'vest/debounce';

2. Wrap your Test Callback:

test(
  'username',
  'User already taken',
  debounce(async () => {
    await doesUserExist();
  }, 2000),
);

In the above example, Vest will wait for two seconds before executing the test, and it will be run only once, no matter how many times the suite was invoked during this time period.

Copy link

vercel bot commented Apr 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
vest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2024 9:07pm
vest-next ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2024 9:07pm

@ealush ealush force-pushed the 2024-03-30-debouce branch from 68bde90 to 56a829c Compare April 2, 2024 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant