npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

reactive-flux

v0.1.6

Published

Fluxish model implemented with RxJS

Readme

reactive-flux

Fluxish model implemented with RxJS

I was trying to use React + Flux to build a Dashboard but while reading Flux tutorials I already started to dislike the switch statements and constants that are all over the place.

React and the Flux architecture seem to fit well with RxJS, so this is my take on it.

This is my first JavaScript code so feel free to send pull requests and let me know of any bugs or improvements you can think of. It's inspired by several libraries that try to combine React with Rx but they didn't seem to do exactly what I had in mind.

Installation

npm install reactive-flux

Description

The dispatcher is completely gone. Instead we are using Rx.Subjects as Actions and Stores.

  • An Action can have many Stores subscribed to it
  • A Store can subscribe to many Actions, each with its own handler
  • Additionally it can request to be notified after other stores in case there are any dependencies (Dispatcher.waitFor())
  • React components can subscribe to many Stores as they are subclasses of Rx.Subject

Changelog

  • 0.1.2: Custom function argument for Action. Fixed problem that the library could not be required correctly.

Example

let ReactiveFlux = require('reactive-flux'),
	request = require('superagent'),
	React = require('react'),
	Action = ReactiveFlux.Action,
	Store = ReactiveFlux.Store;

let LoginSucceededAction = Action.make();
let LoginFailedAction = Action.make();

let LoginAction = Action.make((username, password) => {
	request
		.post('/login')
		.send({ username: username, password: password })
		.end(function(err, res){
			if (res.status == 200) {
				LoginSucceededAction(res.body.token);
			} else {
				LoginFailedAction();
			}
		});
});

let LOGIN_TOKEN_KEY = 'token';

class LoginStore extends Store {
	constructor() {
		super();

		// yes, I agree this is superfluous and needs to be changed :)
		this.init();
	}

	init() {
		this.observe(LoginSucceededAction, this.onLoginSucceeded);
		this.observe(LoginFailedAction, this.onLoginFailed);
	}

	onLoginSucceeded(token) {
		window.localStorage.setItem(LOGIN_TOKEN_KEY, token);
	}

	onLoginFailed() {
		window.localStorage.removeItem(LOGIN_TOKEN_KEY);
	}

	getToken() {
		return window.localStorage.getItem(LOGIN_TOKEN_KEY);
	}

	isLoggedIn() {
		return !!this.getToken();
	}
}

var LoginComponent = React.createClass({
	getInitialState() {
		return { isLoggedIn: LoginStore.isLoggedIn() };
	},

	_subscription: {},

	componentDidMount() {
		self = this;
		this._subscription = LoginStore.subscribe(function () {
			if (LoginStore.isLoggedIn()) {
			   // do something useful
			}
		});
	},

	componentWillUnmount() {
		this._subscription.dispose();
	},

	render() {
		return (
			// something
		);
	},

	handleSubmit(e) {
		e.preventDefault();

		let username = this.refs.username.getValue().trim();
		let password = this.refs.password.getValue().trim();

		if (!username || !password) {
			return;
		}

		// call our action
		LoginAction(username, password);
	}
});

// Actions are subjects so we can subscribe to an API or similar
var source = Rx.Observable.fromEvent(document, 'mousemove');
source.subscribe(SomeAction); // All mousemove events will be send to subscribing stores of SomeAction