Add utility to wait for a designated amount of time #160
Open
Description
It's fairly common in many of our projects to have some kind of helper that looks like this:
async function waitFor(duration: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, duration));
}
See:
- https://github.com/MetaMask/test-dapp/blob/0ea6cc7a496eb0049c735b4deffcc0ba9b234281/src/index.js#L624
- https://github.com/MetaMask/metamask-sdk/blob/55c1dd327affdef9dd6c308898d1f6b808a1ad8f/packages/sdk/src/utils/wait.ts#L1
- https://github.com/MetaMask/metamask-extension/blob/0e5c05ad3b68f80712b976583e4092551bc4aaee/development/lib/retry.js#L34
- https://github.com/MetaMask/metamask-desktop/blob/92fb331eea05004b03d810ba474dcd3e4d9f7fb1/packages/app/src/app/utils/sleep.ts#L1
- https://github.com/MetaMask/eth-json-rpc-infura/blob/dc19a35091a436f8c654514a40deac047866f9f5/src/create-infura-middleware.ts#L248C1-L248C1
We should add that here too.
Metadata
Assignees
Labels
No labels