# wait

The `wait` function is meant to wait a minimum amount of time after an action has been completed before completing the promise. This function also takes into account that if the same callback gets called sequentially before the specified minimum amount of time, then the timer is reset. A practical usage for this would be to display a loading indicator while a user performs an action, and then once the action is complete an HTTP request could be sent. And once the HTTP request has returned, the promise could be resolved. Additionally, the promise could be resolved immediately after the time expires.

### Basic Example

Click the button and wait 2 seconds for it complete. You can choose to resolve the promise early, but it won't actually resolve for 2 seconds.

The promise was resolved! The promise was rejected! The wait has finished, now waiting 10 seconds for the promise to resolve. Click "Resolve Promise" to skip this wait. Start Timer Restart Timer! Resolve Promise Reject Promise