An open API service indexing awesome lists of open source software.

https://github.com/andrepolischuk/wait-for-target

Wait for a target is ready
https://github.com/andrepolischuk/wait-for-target

ready target wait

Last synced: 2 months ago
JSON representation

Wait for a target is ready

Awesome Lists containing this project

README

        

# wait-for-target [![Build Status][travis-image]][travis-url]

> Wait for a target is ready

## Install

```sh
npm install --save wait-for-target
```

## Usage

```js
import waitForTarget from 'wait-for-target'

async function push (...args) {
const analytics = await waitForTarget(() => window.ga)

analytics('send', 'event', ...args)
}

push('ready')
```

## API

### waitForTarget(getTarget[, timeout])

Return a promise that resolves to target when ready.

#### getTarget

Type: `function`

Function returns a target for resolve.

#### timeout

Type: `number`
Default: `Infinity`

Waiting timeout.

## License

MIT

[travis-url]: https://travis-ci.org/andrepolischuk/wait-for-target
[travis-image]: https://travis-ci.org/andrepolischuk/wait-for-target.svg?branch=master