# jr-broadcast

> simple events broadcasting using list of callbacks

Latest version **1.0.0** (published 2018-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install jr-broadcast
pnpm add jr-broadcast
yarn add jr-broadcast
bun add jr-broadcast
```

## 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.0 |
| Published | 2018-03-23 |
| First published | 2018-03-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 25.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | 'dudiq' |
| Maintainers | dudiq |
| Keywords | broadcast, pubsub, events, callback, syncronous, namespace |

## Links

- npm: https://www.npmjs.com/package/jr-broadcast
- Repository: https://github.com/dudiq/broadcast
- Homepage: https://github.com/dudiq/broadcast#readme
- Issues: https://github.com/dudiq/broadcast/issues
- npm.io page: https://npm.io/package/jr-broadcast

## 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.0 (latest) — 2018-03-23

## README

#Broadcast

simple events broadcasting using list of callbacks

methods:
 `on, off, one, trig, aTrig, clean, events, getAllEvents`
 
Rules for how to use:
 
- messages can be with any symbol, except ".", because it is identifier for namespace
- namespace MUST BE start from "." symbol. it's for separate from messages
- maximum arguments for .trig() = 3, if you need more arguments for send data, use object structures

examples:

```
// will create group of events with collision detect
var eventsGroup = broadcast.events('my-group', {
    myEv1: 'myEv1',
    myEv2: 'myEv2'
})


var eventsGroup2 = broadcast.events('my-group-2', {
    myEv1: 'myEv1',
    myEv2: 'myEv2'
})

broadcast.trig(evs.myEv1, opt1, opt2); - will trigger message with arguments

// will return evs group
var evs = broadcast.events('my-group');

// bind handler to evs.myEv1 = 'my-group' trigger
broadcast.on(evs.myEv1, function(params){
  console.log(params.params1); //see 'ohh now'
});

```

```
// 'myHandler' will call only once
broadcast.one('my-event', '.my-namespace', myHandler);

// bind to different messages to 'myHandler'
broadcast.on(['my-event1', 'my-event2'], '.my-namespace', myHandler);


// unbind all callbacks from MESSAGE
broadcast.off('my-event');

unbind all callbacks from NAMESPACE
broadcast.off('.namespace');

// will trigger immedially from current point
broadcast.trig('my-event', {param1: 'ohh now', param2: 2}); // or without params

// will trigger after current callstack is done
broadcast.aTrig('my-event', params);
```

licence: MIT, dudiq 2012

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