andrepolischuk / wait-for-target

Wait for a target is ready

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wait-for-target Build Status

Wait for a target is ready

Install

npm install --save wait-for-target

Usage

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

About

Wait for a target is ready

License:MIT License


Languages

Language:JavaScript 100.0%