0.1.0 • Published 8 years ago

on-ready v0.1.0

Weekly downloads
19
License
MIT
Repository
github
Last release
8 years ago

on-ready

Wait for a list of readyable objects to be ready. Objects used must have two qualifications:

  1. has an on method
  2. emits a ready event
  3. has or can have a ready boolean flag to note if ready

Install

With npm

npm install on-ready

Usage

Node.js

var onReady = require('on-ready')

// use on some redis clients
var redis = require('redis')
  , client1 = redis.createClient()
  , client2 = redis.createClient()

onReady([client1, client2], function(err) {
  // ...

  client1.ready // true
  client2.ready // true
})

// can call using arguments
onReady(client1, client2, function() { 
  // ...
})

// repeated calls still work fine
onReady([client1], [client2], function() { 
  // ...
})