Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.
/ rx-emitter Public archive

🍩 Reactive emitter based on rxjs streams and Rx.Subject

License

Notifications You must be signed in to change notification settings

zemd/rx-emitter

Repository files navigation

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

About

🍩 Reactive emitter based on rxjs streams and Rx.Subject

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published