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 🙏

© 2024 – Pkg Stats / Ryan Hefner

fluxxy

v0.1.13

Published

Fluxxy ==== [![Build Status](https://travis-ci.org/Label305/Fluxxy.svg?branch=master)](https://travis-ci.org/Label305/Fluxxy)

Downloads

8

Readme

Fluxxy

Build Status

More beautiful and scalable implementation of the Flux architecture for React applications.

Installation

Fluxxy can be downloaded as standalone browser build from the GitHub releases page or installed via Bower:

bower install fluxxy

Or npm:

npm install fluxxy 

Usage

So, you've read about the Flux architecture. That means you know about its corner stones: Actions, Dispatching, Stores and Views. Fluxxy also has those, but we've made things more scaleable by using multiple collections of commands which are tied to stores using a namespace.

Time for an example:

Commands:

var TodoCommands = function (events) {
    this.add = function (newTodo) {
        events.dispatch('add', newTodo);
    }
};

Store:

var TodoStore = function (store) {
    this.construct = function (events) {
        events.on('Todo', 'add', this.add);
    };
    this.add = function (newTodo) {
        store.add(newTodo);
        store.changed();
    };
    this.all = function () {
        return store.all();
    }
};

React:

var Fluxxy = require('fluxxy');
var TodoApp = React.createClass({
    mixins: [Fluxxy.watch(['Todo'])],
    getStoreState: function () {
        return {
            todos: this.props.flux.store('Todo').all()
        };
    },
    handleSomething: function() {
        this.props.flux.commands('Todo').add({
            content: 'Dummy todo'
        });
    },
    render: function () {
        var todos = this.state.todos.map(function (todo) {
            return <li onClick={this.handleSomething}>{todo.content}</li>;
        }.bind(this);
        return <div>
            <ul>{todos}</ul>
        </div>;
    }
});

Fluxxy!

var Fluxxy = require('fluxxy');
var fluxxy = new Fluxxy();
fluxxy.command('Todo', TodoCommands);
fluxxy.store('Todo', TodoStore);

We have a collection of commands called TodoCommands, in this case add, which can dispatch an add event within the namespace it is registered to (i.e. Todo, but don't worry, there are overrides). Now you have the TodoStore, which, after it is constructed, listens to these events.

Now data pours into your store, so you have to manage the state there. We've thrown in a default store object for free where you can dump your state, since you'll always implement methods such as all, or add.

Only thing left is to get data into your (React) views, by including a watching Mixin, where you can specify which stores it should watch.

ES6

Since the ES6 classes of React do not have mixins we need another solution. You'll just have to register your component with Fluxxy on construct:

class Comment extends React.Component {
    constructor(props) {
        super(props);
        Fluxxy.watch(['User'], this);
    }
}

Both stores and command hubs will also work in an ES6 environment:

class UserStore {
    constructor(store, events) {
        this.store = store;
        events.on('User', 'add', this.add);
    }
    add(user) {
        this.store.addOrUpdate(user);
    }  
} 

or a command hub:

class UserCommands {
    constructor(events) {
        this.events = events; 
    }
    add(user) {
        this.events.dispatch('add', {
            user: user
        });
    }
}

Drafting a release

When drafting a new release we want to pack our repo so people on the web will be able to use it. For this we use Webpack. So you'll have to run the following commands:

./node_modules/.bin/webpack
cd examples/basic-todo
../../node_modules/.bin/webpack

License

Copyright 2015 Label305 B.V.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.