# next-event

> Call a function the next time a specific event is emitted

Latest version **1.0.0** (published 2015-10-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install next-event
pnpm add next-event
yarn add next-event
bun add next-event
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-10-31 |
| First published | 2015-10-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Mathias Buus |
| Maintainers | mafintosh |

## Links

- npm: https://www.npmjs.com/package/next-event
- Repository: https://github.com/mafintosh/next-event
- Issues: https://github.com/mafintosh/next-event/issues
- npm.io page: https://npm.io/package/next-event

## Recent versions

- 1.0.0 (latest) — 2015-10-31

## README

# next-event

Call a function the next time a specific event is emitted

```
npm install next-event
```

[![build status](http://img.shields.io/travis/mafintosh/next-event.svg?style=flat)](http://travis-ci.org/mafintosh/next-event)

Basically like `.once` but faster.

## Usage

``` js
var nextEvent = require('next-event')

var ontest = nextEvent(emitter, 'test')

ontest(function () {
  console.log('i am only called once')
})

emitter.emit('test')
emitter.emit('test')
```

Note that only the last function you pass to `ontest` in the above example
will be called when the next event is emitted

``` js
ontest(function () {
  console.log('i am never called')
})

ontest(function () {
  console.log('i win because i was the last one')
})

emitter.test('test')
```

## API

#### `var once = nextEvent(emitter, name)`

Create a new once function. Pass an event handler to once
that should be called the next time `name` is emitted.

## License

MIT

---
_Source: https://npm.io/package/next-event · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
