immutable-redux
    TypeScript icon, indicating that this package has built-in type declarations

    0.3.0 • Public • Published

    Immutable Redux Version Build Status Dependency Status Coverage Status

    Provides utilities for dealing with Immutable data structures in Redux.

    Installation

    To install the stable version along with Immutable and Redux, run the following:

    $ npm install --save immutable-redux immutable redux
    

    This assumes that you're using the npm package manager with a module bundler like Webpack or Browserify.

    If you don't yet use npm or a modern module bundler, and would rather prefer a single-file UMD build that makes ImmutableRedux available as a global object, you can build it yourself by running the following:

    $ npm run build
    

    You'll find the development (immutable-redux.js) and production (immutable-redux.min.js) versions of the library in the dist folder. I don't recommend this approach for any serious application.

    Usage

    import {List} from 'immutable'
    import {createStore} from 'redux'
    import {combineImmutableReducers} from 'immutable-redux'
     
    const reducer = combineImmutableReducers({
      counter: (state = 0, action) =>
        action.type === 'INCREMENT' ? state + 1 : state,
      stack: (state = List(), action) =>
        action.type === 'PUSH' ? state.push(action.payload) : state
    })
     
    let store = createStore(reducer)
     
    store.subscribe(() =>
      console.log(store.getState())
    )
     
    store.dispatch({type: 'INCREMENT'})
    // => Map { "counter": 1, "stack": List [] }
    store.dispatch({type: 'PUSH', payload: 'a'})
    // => Map { "counter": 1, "stack": List [ "a" ] }

    Meta

    Contributors

    License

    Copyright (c) 2015 Daniel Perez Alvarez (unindented.org). This is free software, and may be redistributed under the terms specified in the LICENSE file.

    Keywords

    none

    Install

    npm i immutable-redux

    DownloadsWeekly Downloads

    11

    Version

    0.3.0

    License

    MIT

    Last publish

    Collaborators

    • unindented