# eventcb

> One trigger can invoke all the subscribed callbacks events, Can create any number of triggers and each trigger can have any number of event subscribers

Latest version **1.0.12** (published 2019-10-20) · ISC license · 0 weekly downloads

## Install

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

## 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.12 |
| Published | 2019-10-20 |
| First published | 2019-10-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Bobby Thomas |
| Maintainers | bobtxt |
| Keywords | trigger, events, components, callback, cb, multiple, reactjs, react, javascript |

## Links

- npm: https://www.npmjs.com/package/eventcb
- Repository: https://github.com/AIR-FRAME/events.js
- Homepage: https://github.com/AIR-FRAME
- Issues: https://github.com/AIR-FRAME/events.js/issues
- npm.io page: https://npm.io/package/eventcb

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.12 (latest) — 2019-10-20
- 1.0.11 — 2019-10-20
- 1.0.10 — 2019-10-18
- 1.0.8 — 2019-10-18
- 1.0.7 — 2019-10-18
- 1.0.6 — 2019-10-17
- 1.0.5 — 2019-10-17
- 1.0.4 — 2019-10-17
- 1.0.3 — 2019-10-17
- 1.0.2 — 2019-10-17
- 1.0.1 — 2019-10-17
- 1.0.0 — 2019-10-17

## README

# One trigger can invoke all the subscribed callbacks events
## Can create any number of triggers and each trigger can have any number of event subscribers
## Ultra-light code, ~400 bytes and 15 lines of code

### Subscribing to the events
```js
Events.bind('eventname', myFunction);
```

### Triggering the subscribed events
```js
Events.trigger('eventname');
```


 
## ReactJS EXAMPLE 

### TRIGGER FROM COMPONENT A

```js
import Events from 'eventcb';

<button onClick={()=> Events.trigger('MYDATA-CHANGED') }>Modify</button>
<button onClick={()=> Events.trigger('MYDATA-DELETED') }>Delete</button>
```

### RECEIVED AT COMPONENT B

```js

import Events from 'eventcb';

componentDidMount =()=> {
   Events.bind('MYDATA-CHANGED', this.someActionOnChange);
   Events.bind('MYDATA-DELETED', this.someCleanupOnDelete);
};

```

### RECEIVED AT COMPONENT C

```js

import Events from 'eventcb';

componentDidMount =()=> {
   Events.bind('DATACHANGED', this.someMoreActionOnChange);
};

```

### REMOVE BINDING

```js

import Events from 'eventcb';

componentWillUnmount() {
   Events.unbind('MYDATA-CHANGED');		
};

```


### FLOW
![](https://sc-pictures.s3.amazonaws.com/eventscb.png)

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