Socket
Book a DemoInstallSign in
Socket

redux-convention

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-convention

Facilitates conversion of Flux Standard Action (FSA) to Canonical Composition Action (CCA) and vice-versa.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

redux-convention

Travis build status NPM version

Facilitates conversion of Flux Standard Action (FSA) to Canonical Composition Action (CCA) and vice-versa.

Usage

Function

redux-convention exposes mapper object that in turn defines two functions: fromCCAtoFSA and fromFSAtoCCA. Input is a plan object. Output is a shallow copy of the input with mapped properties.

import {
    mapper
} from 'redux-convention';

let CCAction,
    FSAction;

CCAction = {
    name: 'foo',
    data: {
        foo: 'bar'
    },
    metadata: {
        baz: 'qux'
    }
};

FSAction = mapper.fromCCAtoFSA(CCAction);
CCAction = mapper.fromFSAtoCCA(FSAction);

Middleware

redux-convention exposes middleware object that in turn defines two functions: fromCCAtoFSA and fromFSAtoCCA. These functions are designed to work with Redux middleware, specifically, the applyMiddleware function.

Middleware can be used multiple times to convert FSA to CCA.

import {
    createStore,
    applyMiddleware
} from 'redux';

import {
    middleware as convention
} from 'redux-convention';

import {
     combineReducers
} from 'redux-immutable';

import * as reducers from './reducers';

import Immutable from 'immutable';

let reducer,
    state,
    store;

reducer = combineReducers(reducers);

state = Immutable.Map({});

state = reducer(state, {
    name: `CONSTRUCT`
});

store = applyMiddleware(
    // Middleware that uses CCA.
    convention.fromCCAtoFSA,
    // Middleware that uses FSA.
    convention.fromFSAtoCCA,
    // Middleware that uses CCA.
)(createStore)(reducer, state);

export default store;

Keywords

flux

FAQs

Package last updated on 02 Sep 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