New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

fluxdux

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluxdux

Flux and Redux together


Version published
Maintainers
1
Created

FluxDux

The best of both FLUX and Redux all in one package.

Description

This library is a mixture of both FLUX and Redux's features. Each store will only be keeping its own data state, the state is reduced through store.reduce method. Store does not listen directly to actions, but through an immediate object called the handler. These handlers will listen to actions that being dispatched from view.

For more detail explaination, please follow this tutorial.

Install

Install directly from npm using command-line.

npm install --save fluxdux

Or checkout from github

git checkout https://github.com/nquangtrung/fluxdux

Usage

Please see demo/demo.js for some quick usage example.

Define store with its reducers.

var FluxDux = require('../fluxdux.js');
var store = FluxDux.createStore('notes', {
	initialState : function() { ... },
    add : function(state, data) { 
        /* Add new note to current state and return a new state */ 
        return newState; 
    },
    delete : function(state, data) { 
        /* Remove data from current state and return a new state */ 
        return newState; 
    },
    /* Other reducers here */
});

Define actions.

var actions = FluxDux.createActions(
	[ "add", "delete" ]
);

How handler will connect action and store

FluxDux.handle(actions, {
	add : function(data) {
        store.reduce("add", data);
	},
	delete : function(data) {
        store.reduce("delete", data);
	}
});

Actions can be dispatched through directly calling the method.

actions.add({ text: "text1", author: "author1" });
actions.delete({ index: 1 });
actions.add({ text: "text2", author: "author2" });

NPM package

alt text

FAQs

Package last updated on 31 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts