module.exports = function wait(condition){ return function(handler){ return function(){ var result = condition.apply(this, arguments) result ? handler.apply(this, arguments) : this.once('change', wait(condition)(handler)) } } }