Skip to content

A proxy creator for Redux store to convert immutable objects to JS objects

License

Notifications You must be signed in to change notification settings

nakamura-to/redux-immutable-to-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redux Immutable to JS

A proxy creator for Redux store to convert immutable objects to JS objects.

Motivation

Redux Immutable to JS allows you to convert immutable objects to JS objects automatically when Redux state is required outside reducers.

This library is inspired by Immutable Data Structures and JavaScript.

If you are using Immutable.js in a specific part of your system, don't make anything outside of it access the data structures directly. A good example is Redux and it's single atom app state. If the app state is an Immutable.js object, don't force React components to use Immutable.js' API directly.

Installation

npm install --save redux-immutable-to-js

Example App

$ cd example
$ npm install
$ npm start

Examples of Use

Simple

import { createStore } from 'redux';
import immutableToJS from 'redux-immutable-to-js';
import rootReducer from './reducers/index';

// create a store that has redux-immutable-to-js enabled
const finalCreateStore = immutableToJS()(createStore);

const store = finalCreateStore(rootReducer);

Composition

import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import immutableToJS from 'redux-immutable-to-js';
import rootReducer from './reducers/index';

// create a store that has redux-thunk middleware and redux-immutable-to-js enabled
const finalCreateStore = compose(
  applyMiddleware(thunk),
  immutableToJS()
)(createStore);

const store = finalCreateStore(rootReducer);

License

MIT

About

A proxy creator for Redux store to convert immutable objects to JS objects

Resources

License

Stars

Watchers

Forks

Packages

No packages published