# bus-graph

> Simple event bus with powerfull debugging tools

Latest version **0.0.5** (published 2019-05-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install bus-graph
pnpm add bus-graph
yarn add bus-graph
bun add bus-graph
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2019-05-18 |
| First published | 2019-05-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | https://github.com/nikitarub |
| Maintainers | nikita.rub |
| Keywords | bus, event, observer, pattern observer |

## Links

- npm: https://www.npmjs.com/package/bus-graph
- Repository: https://github.com/studtool/bus
- Homepage: https://github.com/studtool/bus#readme
- Issues: https://github.com/studtool/bus/issues
- npm.io page: https://npm.io/package/bus-graph

## 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

- 0.0.5 (latest) — 2019-05-18
- 0.0.4 — 2019-05-18
- 0.0.3 — 2019-05-14
- 0.0.2 — 2019-05-14
- 0.0.1 — 2019-05-14

## README

# Simple event bus with powerfull debugging tools

## Installation

`npm i --save bus-graph`

## Example 

```js
const Bus = require('bus-graph');

// callback functions for events
function callbackFirst(data){
    console.log(data);
}

function callbackSecond(data){
    console.log("++", data);
}

// simple example
Bus.on("FirstEvent", callbackFirst)

Bus.emit({
    event: "FirstEvent", 
    data: [1,2,3,4]
})


// example with suscription and emittion in nested functions
function higher(){
    function inner(){
        Bus.on("SecondEvent", callbackSecond);  
    }
    inner();
}
higher();

function higherEmitter(){
    function innerEmitter(){
        Bus.emit({
            event: "SecondEvent", 
            data: [1,2,3,4, 5,6]
        });
    }
    innerEmitter();
}

higherEmitter();

let meta = Bus.getMeta();

console.log(meta);
```

### Result

```
[ 1, 2, 3, 4 ]
++ [ 1, 2, 3, 4, 5, 6 ]
{ FirstEvent:
   [ { from: undefined,
       link: '(/path_to_caller_file/index.js:13:5)',
       event: 'FirstEvent',
       callback: 'callbackFirst',
       data: undefined },
     { from: undefined,
       link: '(/path_to_caller_file/index.js:15:5)',
       event: 'FirstEvent',
       callback: undefined,
       data: [Array] } ],
  SecondEvent:
   [ { from: 'inner',
       link: '(/path_to_caller_file/index.js:24:13)',
       event: 'SecondEvent',
       callback: 'callbackSecond',
       data: undefined },
     { from: 'innerEmitter',
       link: '(/path_to_caller_file/index.js:32:13)',
       event: 'SecondEvent',
       callback: undefined,
       data: [Array] } ] }
```

## Turn off debug

```js
const Bus = require('bus-graph');

Bus.setDebug(false); // turn's off debug

// turn on debug
Bus.setDebug(true);
Bus.setDebug();
```

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