2.1.0 • Published 7 years ago

rx-emitter v2.1.0

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
7 years ago

Rx-Emitter

Simple emitter based on Rx.Subject. Version 2+ is based on rxjs 5+

npm version Build Status Code Climate CircleCI dependencies:? devDependencies:?

Installation

npm install rx-emitter

or

yarn add rx-emitter

Usage

import Emitter from 'rx-emitter';
// or
// const Emitter =  require('rx-emitter);

class Application extends Emitter {
}

const app = new Application();

app.subscribe('loaded', () => {
  console.log('Loaded event has been fired successfully!');
});

Rx.Observable.combineLatest(
  app.subject('loaded'),
  app.subject('model-ready')
)
.subscribe(() => {
  console.log('Two events were fired in any order');
});


app.publish('loaded');

Configuration

You can configure emitter with different types of Subject.

Example:

class Application extends Emitter {
  constructor() {
    super({
      loaded: () => new Rx.ReplaySubject(1)
    });

    this.publish('loaded');
  }
}

const app = new Application();
app.subscribe('loaded', () => {
  console.log('Application loaded!');
});

License

Rx-Emitter is released under the Apache 2.0 license.

Donate

npm.io npm.io

2.1.0

7 years ago

2.0.1

7 years ago

1.0.2

7 years ago

2.0.0

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago