Wait-until-defined ⌚️

@common-utilities/wait-until-defined 🧰

Typed with TypeScript npm version

Wait Until Defined is a common utility that waits and checks for a callback function to returns true. This is useful to wait until data is defined.

Install

yarn add @common-utilities/wait-until-defined -D

Usage

setTimeout(() => (window.Test = 'yay'), 2000)
const hasWindowTest = () => window.Test === 'test'
const test = async () => {
  const check = await waitUntilDefined(hasWindowTest, 50, 3000)
  return check
}
// true

Common Utilities 🧰

No cruft. No bloat. No dependencies.

Simple, typed, functional, documented, and tested javascript utility functions.

View other common utilities on Github.

Last updated

Was this helpful?