Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/xantredev/make-emitted


https://github.com/xantredev/make-emitted

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# Small and simple event emitter
---
![Size](https://badgen.net/bundlephobia/minzip/[email protected])
![Dependecies count](https://badgen.net/bundlephobia/dependency-count/[email protected])
![Npm](https://badgen.net/npm/v/make-emitted)
---
**Uses ES6 Proxies**

Works pretty easy

```js
import makeEmitted from 'make-emitted'

const someObject = {
a: 5,
pow2: (a) => a ** 2
}

const emitted = makeEmitted(someObject)

const id = emitted.on('pow2', () => console.log('pow2 method used'))

emitted.pow2() // pow2 method used
someObject.pow2() // Z-z-z
emitted.pow2() // pow2 method used

emitted.off(id)
emitted.pow2() // Z-z-z
```

## Autocompletion by typescript
![Autocompletion](./imgs/autocompletion.png)