# microevent2

> Event emitter tiny library

Latest version **1.1.0** (published 2016-07-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install microevent2
pnpm add microevent2
yarn add microevent2
bun add microevent2
```

## 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.1.0 |
| Published | 2016-07-04 |
| First published | 2016-07-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alessandro Filippo Annini |
| Maintainers | sunrising |

## Links

- npm: https://www.npmjs.com/package/microevent2
- Repository: https://github.com/sun2rise/microevent2
- Homepage: https://github.com/sun2rise/microevent2#readme
- Issues: https://github.com/sun2rise/microevent2/issues
- npm.io page: https://npm.io/package/microevent2

## Recent versions

- 1.1.0 (latest) — 2016-07-04
- 1.0.13 — 2016-07-04
- 1.0.12 — 2016-07-04
- 1.0.11 — 2016-07-04
- 1.0.10 — 2016-07-04
- 1.0.8 — 2016-07-04
- 1.0.7 — 2016-07-04
- 1.0.6 — 2016-07-04
- 1.0.5 — 2016-07-04
- 1.0.4 — 2016-07-04
- 1.0.3 — 2016-07-04
- 1.0.2 — 2016-07-04
- 1.0.1 — 2016-07-04
- 1.0.0 — 2016-07-04

## README

microevent2.js
==============

*microevent2.js* is a event emitter library which provides the [observer pattern](http: //en.wikipedia.org/wiki/Observer_pattern) to javascript objects.

It works on ES6, node.js and browser. It is a single.js file containing

< a href = "https://raw.githubusercontent.com/sun2rise/microevent2/master/dist/microevent2.js" >

Usage
-----

You need a single file [microevent2.js](https://raw.githubusercontent.com/sun2rise/microevent2/master/dist/microevent2.js). Include it in a webpage via the usual script tag.

```html
<script src="microevent2.js"> </script>
```

```js
var microevent2 = new MicroEvent2();

microevent2.on('some-event', someCallback);
microevent2.emit('some-event');
```

or

```js
import MicroEvent2 from 'MicroEvent2';
let Object = function () {
  MicroEvent2.mixin(this);
  this.emit('ev.name', data);
}
```

or

```js
var Microevent2 = require('microevent2')
```

Instance Methods
----------------

### on(event, callback)

Subscribe to an event

-	`event` - the name of the event to subscribe to
-	`callback` - the function to call when event is emitted

### once(event, callback[, context])

Subscribe to an event only **once**

-	`event` - the name of the event to subscribe to
-	`callback` - the function to call when event is emitted

### off(event[, callback])

Unsubscribe from an event or all events.

-	`event` - the name of the event to unsubscribe from
-	`callback` - the function used when binding to the event

### emit(event[, arguments...])

Trigger a named event

-	`event` - the event name to emit
-	`arguments...` - any number of arguments to pass to the event subscribers

### pipe(eventEmitter)

Push events downstream from the handler to another

-	`eventEmitter` - the event emitter to pipe (to emit to)

### unpipe(eventEmitter)

Unpipe events to the previously piped event emitter

-	`eventEmitter` - the event emitter to unpipe

### mixin(destObject)

Mixin will delegate all microevent2 function in the destination object

-	`destObject` - the object which will support microevent2

### bind

For compatibility, see `on`

### unbind

For compatibility, see `off`

### trigger

For compatibility, see `emit`

Example
-------

see inside `test` folder

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