Comparing version 0.2.2 to 0.2.3
{ | ||
"name": "chnl", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Chrome compatible javascript channels", | ||
@@ -5,0 +5,0 @@ "main": "./es5/index.js", |
@@ -21,3 +21,4 @@ # Chrome compatible javascript channels | ||
## Channel | ||
Channel is class that can attach/detach listeners and dispatch data to them. | ||
Channel is class that can attach/detach listeners and dispatch data to them. | ||
This allows to make more independent modules that just produce events in outer world. | ||
API: | ||
@@ -37,3 +38,2 @@ | ||
```js | ||
// import es5 code | ||
import Channel from 'chnl'; | ||
@@ -44,3 +44,3 @@ | ||
// dispatch event when needed | ||
// dispatch event (and don't care if there module B and what it will do with event) | ||
exports.onChanged.dispatch(data); | ||
@@ -74,3 +74,3 @@ ``` | ||
Not all methods of original nodejs [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) | ||
are supported but most popular: | ||
are supported but most needed: | ||
@@ -84,8 +84,6 @@ * addListener / on | ||
```js | ||
import Channel from 'chnl'; | ||
import {EventEmitter} from 'chnl'; | ||
// use as standalone object | ||
const emitter = new EventEmitter(); | ||
const emitter = new Channel.EventEmitter(); | ||
emitter.on('event', data => console.log(data)); | ||
@@ -95,4 +93,3 @@ emitter.emit('event', 'hello world!'); // output 'hello world!' | ||
// use as parent for some class | ||
class MyClass extends EventEmitter { | ||
class MyClass extends Channel.EventEmitter { | ||
someMethod() { | ||
@@ -117,2 +114,4 @@ this.emit('event', 'hello world!') | ||
```js | ||
import Channel from 'chnl'; | ||
this._subscription = new Channel.Subscription([ | ||
@@ -119,0 +118,0 @@ { |
48090
126