You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

redux-query-immutable

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-query-immutable

A fork of redux-query with support for ImmutableJS

2.0.0
Source
npmnpm
Version published
Weekly downloads
226
-22.87%
Maintainers
1
Weekly downloads
 
Created
Source

redux-query-immutable

npm

redux-query-immutable is a fork of the redux-query library, with the only difference that it supports a redux store based on ImmutableJS.

Please refer to the documentation of redux-query for details of the API.

Getting Started

Install redux-query-immutable via npm:

$ npm install --save redux-query-immutable

Add the entitiesReducer and queriesReducer to your combined reducer.

Include the queryMiddleware in your store's applyMiddleware call. queryMiddleware requires two arguments: a selector (or function) that returns entities state, and a function for the queries state.

For example:

import { applyMiddleware, createStore } from 'redux';
import { combineReducers } from 'redux-immutable'
import { entitiesReducer, queriesReducer, queryMiddleware } from 'redux-query-immutable';
import createLogger from 'redux-logger';

export const getQueries = (state) => state.get('queries');
export const getEntities = (state) => state.get('entities');

const reducer = combineReducers({
    entities: entitiesReducer,
    queries: queriesReducer,
});

const logger = createLogger();
const store = createStore(
    reducer,
    applyMiddleware(queryMiddleware(getQueries, getEntities), logger)
);

connectRequest

This is an updated version of the connectRequest higher-order component example from the original redux-query library. The biggest change to the original example is that you now have immutable data in the update functions.

import { connectRequest } from 'redux-query-immutable';
import { connect } from 'react-redux-immutable';

class Dashboard extends Component {
    ...
}

const DashboardContainer = connectRequest((props) => ({
    url: `/api/dashboard/${props.dashboardId}`,
    update: {
        chartsById: (prevCharts, dashboardCharts) => (
            prevCharts.mergeDeep(dashboardCharts)
        ),
        dashboardsById: (prevDashboards, dashboards) => (
            prevDashboards.mergeDeep(dashboards)
        ),
    },
}))(Dashboard);

const mapStateToProps = (state, props) => {
    return {
        dashboard: getDashboard(state, props),
    };
};

export default connect(mapStateToProps)(DashboardContainer);

Keywords

redux

FAQs

Package last updated on 09 Jun 2017

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.