Await until event
Compatible with
- EventEmitter
- EventEmitter2
npm install @strong-roots-capital/until
import { until } from '@strong-roots-capital/until'
test('should await until event', async t => {
class TestClient extends EventEmitter {
open = false
constructor() {
super()
setTimeout(() => {
this.open = true
this.emit('open')
}, 100)
}
}
const client = new TestClient()
await until(client, 'open')
t.true(client.open)
})