3.0.0 • Published 7 years ago

chab v3.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

chab

Build Status npm version

Simple to use implementation of event bus.

As for now needs ES2015.

Usage

NPM

npm install chab --save

Browser

<script type="text/javascript" src="chab.js"></script>

Example with Babel & webpack

import { CreateChab } from 'chab'

const chab = CreateChab()

const sub = chab.subscribe('topicName', data => {
  console.log(`Welcome ${data.name}!`)
})

chab.publish('topicName', { name: 'User' })

sub.unsubscribe()

In browser available from chab namespace

chab.CreateChab()

API

chab instance

subscribe(topic, callback)

Subscribes on given topic. Callback one argument: data which is passed by publish function


publish(topic, data)

Publishes message on given topic. If no subscriber will be found at publish time message gets stored and dispatched when somebody finally subscribes.

3.0.0

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.0

8 years ago

0.10.1

8 years ago

0.10.0

8 years ago

0.9.2

8 years ago

0.9.1

8 years ago

0.9.0

8 years ago

0.8.0

8 years ago

0.7.0

8 years ago