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 🙏

© 2025 – Pkg Stats / Ryan Hefner

redux-update-v1

v0.0.1

Published

redux-immutable utilities

Downloads

3

Readme

Redux-update

Play with Immutable.js state in a react-redux application.

Usage

Define a initialState and create a store

import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import { Store } from "redux-update";


/**  Data-update-type reducers will be created according to the initialState  */
const initialState = {
  application: {
    name: "immutable-state-app"
  },
  user: {
    isLoggedIn: false,
    profile: undefined
  },
  data: {}
};

const options = {
    state: initialState,
    ...otherOptions
};

const appStore = new Store(options);

ReactDOM.render(
  <Provider store={appStore}>
    <User />
    <TodoList />
  </Provider>,
  document.getElementById("root")
);

A Immutable.js state as well as [data-update-type] reducers according to the state would be inited.

Connect the componnet Learn more about redux

import { Store, connect } from "redux-update";

/** Set the [stateKeys] as args */
@connect("user", "data.todo")
class User extend React.Component{

    render() {
        // Get from redux state
        const profile = Store.get("user.profile");
        return (
            <div>
                {user.profile.name}
            </div>
        )
    }

    async updateData() {
        const newData = await fetch("fetchData");
        // Store.update() will dispatch a data-update-type action
        Store.update("user.profile", newData);
    }
}

@connect("data.todo")
class TodoList extend React.Component{
    render() {
        cosnt list = Store.get("data.todo.list") || [];
        return (
            ...
        )
    }
}

Component would re-render when the connect-state-value changed.

At the situation above, component TodoList would not re-render unless data.todo had changed.

Handle the Immutable.js state

  • connect(...values: Array<string | ConnectRestParams>)

  • Store.update(keys: string, payload: any)

  • Store.updateList(keys: string, type: "update" | "push" | "pop" | "unshift" | "shift", payload: any): void;

  • Store.get(keys: string): T | undefined

  • Store.dispatch(action: StoreAction)

Update List value

function updateListData() {
    const list = [
        {
            id: "a1",
            data: "a1data"
        },
         {
            id: "a2",
            data: "a2data"
        },
        ...
    ];
    // update list in state
    Store.update("list.listdata", list);

    const new_a2 = {
        id: "a2",
        data: "new data",
        ...
    };

    // update value in `list` by id
    Store.updateList("list.listdata", "update", {
        key: "id",
        ...new_a2
    });
}

Options

  • state

  • reducers

  • reducerWhiteList

  • middlewares

Create custom reducers. Configuring router reducer for example

import {
    LOCATION_CHANGE
} from "react-router-redux";
import createHistory from "history/createBrowserHistory";
import {
  ConnectedRouter,
  routerReducer,
  routerMiddleware,
  push
} from "react-router-redux";

const initialState = {
  application: {
    name: "immutable-state-app"
  },
  router: {
    "locationBeforeTransitions": null
  },
  user: {
    isLoggedIn: false,
    profile: undefined
  },
  data: {}
};

function routerReducer(state = Immutable.fromJS(initialState), action) {
    if (action.type === LOCATION_CHANGE) {
        return state.set("locationBeforeTransitions", action.payload);
    }
    return state;
}

/** Add the reducer on the `router` key */
const reducers = {
    router: routerReducer
};

const history = createHistory();
const middleware = routerMiddleware(history);

const options = {
    state: initialState,
    reducers: reducers,
    // Add "router" to whitelist that preventing create data-update type reducers
    reducerWhiteList: ["router"],
    // Apply our middleware for navigating
    middleware: [middleware]
};

const appStore = new Store(options);

ReactDOM.render(
  <Provider store={appStore}>
    <ConnectedRouter history={history}>
      <div>
        <Route exact path="/" component={App} />
      </div>
    </ConnectedRouter>
  </Provider>,
  document.getElementById("root")
);