Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

rx-emitter

zemd14Apache-2.0deprecated2.1.0

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

Simple emitter built on top of Rx Observables

readme

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.