# comlog-event-handler

> Extend object with event handler

Latest version **1.0.2** (published 2017-12-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install comlog-event-handler
pnpm add comlog-event-handler
yarn add comlog-event-handler
bun add comlog-event-handler
```

## 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.2 |
| Published | 2017-12-05 |
| First published | 2017-07-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | COMLOG GmbH |
| Maintainers | comlog.gmbh |
| Keywords | event, handler |

## Links

- npm: https://www.npmjs.com/package/comlog-event-handler
- Homepage: http://www.comlog.org
- npm.io page: https://npm.io/package/comlog-event-handler

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2017-12-05
- 1.0.1 — 2017-07-25
- 1.0.0 — 2017-07-25

## README

# Integrate event handler into your module

Installation via
```sh
$ npm install -s comlog-event-handler
```
# Usage
Module integration
```javascript
var myModule = {
    test: 'abc',
    doSomthing: function() {
        this.trigger('event1', ['arg 1', 'arg2', 'arg3']);
        this.trigger('event1', 'testid');
        this.trigger('event2');
    }
};
require('comlog-event-handler')(myModule);
module.exports = myModule
```

Module usage
```javascript
var myModule = require('myModule');

// bind event
myModule.on('event1', function(arg1, arg2, arg3) {
    console.info(arg1, arg2, arg3)
});

// bind event with id
myModule.on('event1', 'testid', function(arg1, arg2, arg3) {
    console.info(arg1, arg2, arg3);
});

// bind single event (will be removed after call)
myModule.one('event2', function(arg1, arg2, arg3) {
    console.info(arg1, arg2, arg3)
});
// OR
myModule.once('event3', function(arg1, arg2, arg3) {
    console.info(arg1, arg2, arg3)
});

// unbind event by id
myModule.off('event1', 'testid', function(arg1, arg2, arg3) {
	console.info(arg1, arg2, arg3)
});

// unbind all events
myModule.off('event1', function(arg1, arg2, arg3) {
	console.info(arg1, arg2, arg3)
});

myModule.trigger('event1', [arg1, arg2, arg3]);
// OR
myModule.emit('event1', [arg1, arg2, arg3]);

```

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