Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/socker210/event-emitter

A simple event emitter
https://github.com/socker210/event-emitter

Last synced: about 1 month ago
JSON representation

A simple event emitter

Awesome Lists containing this project

README

        

# Event emitter

Simple event emitter like a node

## Installation

With npm
```
npm install @socker210/event-emitter
```

With yarn
```
yarn add @socker210/event-emitter
```

## Usage

```javascript
const EventEmitter = require('@socker210/event-emitter')

const eventEmitter = new EventEmitter()

const cb = () => console.log('callback')

// Register event
eventEmitter.on('print', cb)

// Execute event
eventEmitter.emit('print')

// Check if event is registered
eventEmitter.hasEvent('print')

// Check if event and callback is registered
eventEmitter.hasCallback('print', cb)

// Remove callback
eventEmitter.off('print', cb)
```

## LICENSE

MIT