redux-query
Advanced tools
Comparing version
@@ -11,3 +11,3 @@ 'use strict'; | ||
var _lodash = require('lodash'); | ||
var _lodash = require('lodash.partial'); | ||
@@ -154,3 +154,3 @@ var _lodash2 = _interopRequireDefault(_lodash); | ||
var forceRequest = _lodash2.default.partial(this.requestAsync.bind(this), this.props, true, false); | ||
var forceRequest = (0, _lodash2.default)(this.requestAsync.bind(this), this.props, true, false); | ||
@@ -157,0 +157,0 @@ if (withRef) { |
@@ -11,5 +11,5 @@ 'use strict'; | ||
var _identity = require('lodash/identity'); | ||
var _lodash = require('lodash.identity'); | ||
var _identity2 = _interopRequireDefault(_identity); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
@@ -20,5 +20,5 @@ var _react = require('react'); | ||
var _partial = require('lodash/partial'); | ||
var _lodash3 = require('lodash.partial'); | ||
var _partial2 = _interopRequireDefault(_partial); | ||
var _lodash4 = _interopRequireDefault(_lodash3); | ||
@@ -67,3 +67,3 @@ var _actions = require('../actions'); | ||
var url = mapPropsToUrl(props); | ||
var transform = mapPropsToTransform ? mapPropsToTransform(props) : _identity2.default; | ||
var transform = mapPropsToTransform ? mapPropsToTransform(props) : _lodash2.default; | ||
dispatch((0, _actions.requestAsync)(url, mapStateToRequests, transform, force)); | ||
@@ -75,3 +75,3 @@ } | ||
return _react2.default.createElement(WrappedComponent, _extends({}, this.props, { | ||
forceRequest: (0, _partial2.default)(this.fetch.bind(this), this.props, true) | ||
forceRequest: (0, _lodash4.default)(this.fetch.bind(this), this.props, true) | ||
})); | ||
@@ -78,0 +78,0 @@ } |
@@ -15,6 +15,18 @@ 'use strict'; | ||
var _lodash = require('lodash'); | ||
var _lodash = require('lodash.get'); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _lodash3 = require('lodash.identity'); | ||
var _lodash4 = _interopRequireDefault(_lodash3); | ||
var _lodash5 = require('lodash.includes'); | ||
var _lodash6 = _interopRequireDefault(_lodash5); | ||
var _lodash7 = require('lodash.pickby'); | ||
var _lodash8 = _interopRequireDefault(_lodash7); | ||
var _superagent = require('superagent'); | ||
@@ -78,3 +90,3 @@ | ||
var getPendingQueries = function getPendingQueries(queries) { | ||
return _lodash2.default.pickBy(queries, function (query) { | ||
return (0, _lodash8.default)(queries, function (query) { | ||
return query.isPending; | ||
@@ -104,3 +116,3 @@ }); | ||
_action$transform = action.transform, | ||
transform = _action$transform === undefined ? _lodash2.default.identity : _action$transform, | ||
transform = _action$transform === undefined ? _lodash4.default : _action$transform, | ||
update = action.update, | ||
@@ -122,4 +134,4 @@ _action$options = action.options, | ||
var queriesState = queries[queryKey]; | ||
var isPending = _lodash2.default.get(queriesState, ['isPending']); | ||
var status = _lodash2.default.get(queriesState, ['status']); | ||
var isPending = (0, _lodash2.default)(queriesState, ['isPending']); | ||
var status = (0, _lodash2.default)(queriesState, ['status']); | ||
var hasSucceeded = status >= 200 && status < 300; | ||
@@ -175,3 +187,3 @@ | ||
if (err || !resOk) { | ||
if (_lodash2.default.includes(config.retryableStatusCodes, resStatus) && attempts < config.backoff.maxAttempts) { | ||
if ((0, _lodash6.default)(config.retryableStatusCodes, resStatus) && attempts < config.backoff.maxAttempts) { | ||
// TODO take into account Retry-After header if 503 | ||
@@ -215,3 +227,3 @@ setTimeout(attemptRequest, backoff.duration()); | ||
_action$transform2 = action.transform, | ||
transform = _action$transform2 === undefined ? _lodash2.default.identity : _action$transform2, | ||
transform = _action$transform2 === undefined ? _lodash4.default : _action$transform2, | ||
update = action.update, | ||
@@ -218,0 +230,0 @@ providedQueryKey = action.queryKey, |
@@ -9,3 +9,3 @@ 'use strict'; | ||
var _lodash = require('lodash'); | ||
var _lodash = require('lodash.omit'); | ||
@@ -32,3 +32,3 @@ var _lodash2 = _interopRequireDefault(_lodash); | ||
} else { | ||
return _lodash2.default.omit(state, key); | ||
return (0, _lodash2.default)(state, key); | ||
} | ||
@@ -35,0 +35,0 @@ }; |
@@ -9,9 +9,9 @@ 'use strict'; | ||
var _values = require('lodash/values'); | ||
var _lodash = require('lodash.values'); | ||
var _values2 = _interopRequireDefault(_values); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _includes = require('lodash/includes'); | ||
var _lodash3 = require('lodash.includes'); | ||
var _includes2 = _interopRequireDefault(_includes); | ||
var _lodash4 = _interopRequireDefault(_lodash3); | ||
@@ -43,3 +43,3 @@ var _actionTypes = require('../constants/action-types'); | ||
if ((0, _includes2.default)((0, _values2.default)(actionTypes), action.type)) { | ||
if ((0, _lodash4.default)((0, _lodash2.default)(actionTypes), action.type)) { | ||
return _extends({}, state, _defineProperty({}, action.url, request(state[action.url], action))); | ||
@@ -46,0 +46,0 @@ } else { |
@@ -8,3 +8,3 @@ 'use strict'; | ||
var _lodash = require('lodash'); | ||
var _lodash = require('lodash.get'); | ||
@@ -21,3 +21,3 @@ var _lodash2 = _interopRequireDefault(_lodash); | ||
return function (queriesState) { | ||
return _lodash2.default.get(queriesState, [(0, _getQueryKey2.default)(url, body), 'isFinished']); | ||
return (0, _lodash2.default)(queriesState, [(0, _getQueryKey2.default)(url, body), 'isFinished']); | ||
}; | ||
@@ -28,3 +28,3 @@ }; | ||
return function (queriesState) { | ||
return _lodash2.default.get(queriesState, [(0, _getQueryKey2.default)(url, body), 'isPending']); | ||
return (0, _lodash2.default)(queriesState, [(0, _getQueryKey2.default)(url, body), 'isPending']); | ||
}; | ||
@@ -35,3 +35,3 @@ }; | ||
return function (queriesState) { | ||
return _lodash2.default.get(queriesState, [(0, _getQueryKey2.default)(url, body), 'status']); | ||
return (0, _lodash2.default)(queriesState, [(0, _getQueryKey2.default)(url, body), 'status']); | ||
}; | ||
@@ -42,3 +42,3 @@ }; | ||
return function (queriesState) { | ||
return _lodash2.default.get(queriesState, [(0, _getQueryKey2.default)(url, body), 'lastUpdated']); | ||
return (0, _lodash2.default)(queriesState, [(0, _getQueryKey2.default)(url, body), 'lastUpdated']); | ||
}; | ||
@@ -49,4 +49,4 @@ }; | ||
return function (queriesState) { | ||
return _lodash2.default.get(queriesState, [(0, _getQueryKey2.default)(url, body), 'queryCount']); | ||
return (0, _lodash2.default)(queriesState, [(0, _getQueryKey2.default)(url, body), 'queryCount']); | ||
}; | ||
}; |
@@ -11,3 +11,3 @@ 'use strict'; | ||
var _lodash = require('lodash'); | ||
var _lodash = require('lodash.partial'); | ||
@@ -154,3 +154,3 @@ var _lodash2 = _interopRequireDefault(_lodash); | ||
var forceRequest = _lodash2.default.partial(this.requestAsync.bind(this), this.props, true, false); | ||
var forceRequest = (0, _lodash2.default)(this.requestAsync.bind(this), this.props, true, false); | ||
@@ -157,0 +157,0 @@ if (withRef) { |
@@ -11,5 +11,5 @@ 'use strict'; | ||
var _identity = require('lodash/identity'); | ||
var _lodash = require('lodash.identity'); | ||
var _identity2 = _interopRequireDefault(_identity); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
@@ -20,5 +20,5 @@ var _react = require('react'); | ||
var _partial = require('lodash/partial'); | ||
var _lodash3 = require('lodash.partial'); | ||
var _partial2 = _interopRequireDefault(_partial); | ||
var _lodash4 = _interopRequireDefault(_lodash3); | ||
@@ -67,3 +67,3 @@ var _actions = require('../actions'); | ||
var url = mapPropsToUrl(props); | ||
var transform = mapPropsToTransform ? mapPropsToTransform(props) : _identity2.default; | ||
var transform = mapPropsToTransform ? mapPropsToTransform(props) : _lodash2.default; | ||
dispatch((0, _actions.requestAsync)(url, mapStateToRequests, transform, force)); | ||
@@ -75,3 +75,3 @@ } | ||
return _react2.default.createElement(WrappedComponent, _extends({}, this.props, { | ||
forceRequest: (0, _partial2.default)(this.fetch.bind(this), this.props, true) | ||
forceRequest: (0, _lodash4.default)(this.fetch.bind(this), this.props, true) | ||
})); | ||
@@ -78,0 +78,0 @@ } |
@@ -15,6 +15,18 @@ 'use strict'; | ||
var _lodash = require('lodash'); | ||
var _lodash = require('lodash.get'); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _lodash3 = require('lodash.identity'); | ||
var _lodash4 = _interopRequireDefault(_lodash3); | ||
var _lodash5 = require('lodash.includes'); | ||
var _lodash6 = _interopRequireDefault(_lodash5); | ||
var _lodash7 = require('lodash.pickby'); | ||
var _lodash8 = _interopRequireDefault(_lodash7); | ||
var _superagent = require('superagent'); | ||
@@ -78,3 +90,3 @@ | ||
var getPendingQueries = function getPendingQueries(queries) { | ||
return _lodash2.default.pickBy(queries, function (query) { | ||
return (0, _lodash8.default)(queries, function (query) { | ||
return query.isPending; | ||
@@ -104,3 +116,3 @@ }); | ||
_action$transform = action.transform, | ||
transform = _action$transform === undefined ? _lodash2.default.identity : _action$transform, | ||
transform = _action$transform === undefined ? _lodash4.default : _action$transform, | ||
update = action.update, | ||
@@ -122,4 +134,4 @@ _action$options = action.options, | ||
var queriesState = queries[queryKey]; | ||
var isPending = _lodash2.default.get(queriesState, ['isPending']); | ||
var status = _lodash2.default.get(queriesState, ['status']); | ||
var isPending = (0, _lodash2.default)(queriesState, ['isPending']); | ||
var status = (0, _lodash2.default)(queriesState, ['status']); | ||
var hasSucceeded = status >= 200 && status < 300; | ||
@@ -175,3 +187,3 @@ | ||
if (err || !resOk) { | ||
if (_lodash2.default.includes(config.retryableStatusCodes, resStatus) && attempts < config.backoff.maxAttempts) { | ||
if ((0, _lodash6.default)(config.retryableStatusCodes, resStatus) && attempts < config.backoff.maxAttempts) { | ||
// TODO take into account Retry-After header if 503 | ||
@@ -215,3 +227,3 @@ setTimeout(attemptRequest, backoff.duration()); | ||
_action$transform2 = action.transform, | ||
transform = _action$transform2 === undefined ? _lodash2.default.identity : _action$transform2, | ||
transform = _action$transform2 === undefined ? _lodash4.default : _action$transform2, | ||
update = action.update, | ||
@@ -218,0 +230,0 @@ providedQueryKey = action.queryKey, |
@@ -9,3 +9,3 @@ 'use strict'; | ||
var _lodash = require('lodash'); | ||
var _lodash = require('lodash.omit'); | ||
@@ -32,3 +32,3 @@ var _lodash2 = _interopRequireDefault(_lodash); | ||
} else { | ||
return _lodash2.default.omit(state, key); | ||
return (0, _lodash2.default)(state, key); | ||
} | ||
@@ -35,0 +35,0 @@ }; |
@@ -9,9 +9,9 @@ 'use strict'; | ||
var _values = require('lodash/values'); | ||
var _lodash = require('lodash.values'); | ||
var _values2 = _interopRequireDefault(_values); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _includes = require('lodash/includes'); | ||
var _lodash3 = require('lodash.includes'); | ||
var _includes2 = _interopRequireDefault(_includes); | ||
var _lodash4 = _interopRequireDefault(_lodash3); | ||
@@ -43,3 +43,3 @@ var _actionTypes = require('../constants/action-types'); | ||
if ((0, _includes2.default)((0, _values2.default)(actionTypes), action.type)) { | ||
if ((0, _lodash4.default)((0, _lodash2.default)(actionTypes), action.type)) { | ||
return _extends({}, state, _defineProperty({}, action.url, request(state[action.url], action))); | ||
@@ -46,0 +46,0 @@ } else { |
@@ -8,3 +8,3 @@ 'use strict'; | ||
var _lodash = require('lodash'); | ||
var _lodash = require('lodash.get'); | ||
@@ -21,3 +21,3 @@ var _lodash2 = _interopRequireDefault(_lodash); | ||
return function (queriesState) { | ||
return _lodash2.default.get(queriesState, [(0, _getQueryKey2.default)(url, body), 'isFinished']); | ||
return (0, _lodash2.default)(queriesState, [(0, _getQueryKey2.default)(url, body), 'isFinished']); | ||
}; | ||
@@ -28,3 +28,3 @@ }; | ||
return function (queriesState) { | ||
return _lodash2.default.get(queriesState, [(0, _getQueryKey2.default)(url, body), 'isPending']); | ||
return (0, _lodash2.default)(queriesState, [(0, _getQueryKey2.default)(url, body), 'isPending']); | ||
}; | ||
@@ -35,3 +35,3 @@ }; | ||
return function (queriesState) { | ||
return _lodash2.default.get(queriesState, [(0, _getQueryKey2.default)(url, body), 'status']); | ||
return (0, _lodash2.default)(queriesState, [(0, _getQueryKey2.default)(url, body), 'status']); | ||
}; | ||
@@ -42,3 +42,3 @@ }; | ||
return function (queriesState) { | ||
return _lodash2.default.get(queriesState, [(0, _getQueryKey2.default)(url, body), 'lastUpdated']); | ||
return (0, _lodash2.default)(queriesState, [(0, _getQueryKey2.default)(url, body), 'lastUpdated']); | ||
}; | ||
@@ -49,4 +49,4 @@ }; | ||
return function (queriesState) { | ||
return _lodash2.default.get(queriesState, [(0, _getQueryKey2.default)(url, body), 'queryCount']); | ||
return (0, _lodash2.default)(queriesState, [(0, _getQueryKey2.default)(url, body), 'queryCount']); | ||
}; | ||
}; |
{ | ||
"name": "redux-query", | ||
"version": "1.0.1", | ||
"description": "Library for React/Redux apps that use REST APIs to synchronize and manage network state", | ||
"version": "1.0.2", | ||
"description": "A library for querying and managing network state in React/Redux applications", | ||
"main": "dist/commonjs/index.js", | ||
@@ -40,3 +40,9 @@ "module": "dist/es/index.js", | ||
"json-stable-stringify": "^1.0.0", | ||
"lodash": "^4.8.0", | ||
"lodash.get": "^4.4.2", | ||
"lodash.identity": "^3.0.0", | ||
"lodash.includes": "^4.3.0", | ||
"lodash.omit": "^4.5.0", | ||
"lodash.partial": "^4.2.1", | ||
"lodash.pickby": "^4.6.0", | ||
"lodash.values": "^4.3.0", | ||
"react": "^15.0.1", | ||
@@ -43,0 +49,0 @@ "react-pure-render": "^1.0.2", |
@@ -7,3 +7,3 @@ # redux-query | ||
`redux-query` is a library for React/Redux apps that use REST APIs to synchronize and manage network state. | ||
`redux-query` is a library for querying and managing network state in React/Redux applications. | ||
@@ -17,4 +17,4 @@ With `redux-query` you can: | ||
- Perform optimistic updates. | ||
- Use in conjunction with other Redux libraries [redux-thunk](https://github.com/gaearon/redux-thunk) and [redux-saga](https://github.com/redux-saga/redux-saga). | ||
- Debug network state and actions with Redux dev tools (e.g. [redux-logger](https://github.com/evgenyrodionov/redux-logger)). | ||
- Use with other Redux middleware libraries like [redux-thunk](https://github.com/gaearon/redux-thunk) and [redux-saga](https://github.com/redux-saga/redux-saga). | ||
- Debug network state and actions with Redux dev tools like [redux-logger](https://github.com/evgenyrodionov/redux-logger). | ||
@@ -31,3 +31,3 @@ ## Getting Started | ||
Include the `queryMiddleware` to your store's `applyMiddleware` call. `queryMiddleware` requires two arguments: a function (selector) that returns entities state, and a function for the queries state. | ||
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. | ||
@@ -56,2 +56,6 @@ For example: | ||
## Dependencies | ||
All dependencies are listed in [`package.json`](./package.json). Redux and React are peer dependencies. HTTP requests are made using [superagent](https://github.com/visionmedia/superagent). | ||
## Usage and API | ||
@@ -69,5 +73,5 @@ | ||
Query configs are objects used to describe how redux-query should handle the request or mutation. | ||
Query configs are objects used to describe how redux-query should handle the request or mutation. Query config options differ slightly between requests and mutations | ||
Query configs for requests have the following options: | ||
#### Request query config options | ||
@@ -85,3 +89,3 @@ | Name | Type | Required? | Description | | ||
Query configs for mutations are slightly different. They have the following options: | ||
#### Mutation query config options | ||
@@ -128,3 +132,3 @@ | Name | Type | Required? | Description | | ||
Use the `connectRequest` higher-order component to declare network dependencies for a React component. `connectRequest` takes a function that transforms the component `props` to a query config. Example usage: | ||
Use the `connectRequest` higher-order component to declare network dependencies for a React component. `connectRequest` takes a function that transforms the component `props` to a request query config. Example usage: | ||
@@ -165,3 +169,3 @@ ```javascript | ||
Dispatch `mutateAsync` Redux actions to trigger mutations. Example usage with a [react-redux](https://github.com/reactjs/react-redux)-connected component: | ||
Dispatch `mutateAsync` Redux actions to trigger mutations. `mutateAsync` takes a mutation query config as its only argument. Example usage with a [react-redux](https://github.com/reactjs/react-redux)-connected component: | ||
@@ -200,2 +204,3 @@ ```javascript | ||
} | ||
}; | ||
@@ -248,3 +253,3 @@ // src/components/Dashboard.jsx | ||
Similarly to how mutations are triggered by dispatching `mutateAsync` actions, you can trigger requests by dispatching `requestAsync` actions. | ||
Similarly to how mutations are triggered by dispatching `mutateAsync` actions, you can trigger requests by dispatching `requestAsync` actions with a request query config. | ||
@@ -251,0 +256,0 @@ ## Example |
@@ -1,2 +0,2 @@ | ||
import _ from 'lodash'; | ||
import partial from 'lodash.partial'; | ||
import React from 'react'; | ||
@@ -91,3 +91,3 @@ import shallowEqual from 'react-pure-render/shallowEqual'; | ||
render() { | ||
const forceRequest = _.partial(this.requestAsync.bind(this), this.props, true, false); | ||
const forceRequest = partial(this.requestAsync.bind(this), this.props, true, false); | ||
@@ -94,0 +94,0 @@ if (withRef) { |
@@ -1,4 +0,4 @@ | ||
import identity from 'lodash/identity'; | ||
import identity from 'lodash.identity'; | ||
import React, { Component } from 'react'; | ||
import partial from 'lodash/partial'; | ||
import partial from 'lodash.partial'; | ||
@@ -5,0 +5,0 @@ import { requestAsync } from '../actions'; |
import Backoff from 'backo'; | ||
import invariant from 'invariant'; | ||
import _ from 'lodash'; | ||
import get from 'lodash.get'; | ||
import identity from 'lodash.identity'; | ||
import includes from 'lodash.includes'; | ||
import pickBy from 'lodash.pickby'; | ||
import superagent from 'superagent'; | ||
@@ -57,3 +60,3 @@ | ||
const getPendingQueries = (queries) => { | ||
return _.pickBy(queries, (query) => query.isPending); | ||
return pickBy(queries, (query) => query.isPending); | ||
}; | ||
@@ -73,3 +76,3 @@ | ||
retry, | ||
transform = _.identity, | ||
transform = identity, | ||
update, | ||
@@ -90,4 +93,4 @@ options = {}, | ||
const queriesState = queries[queryKey]; | ||
const isPending = _.get(queriesState, ['isPending']); | ||
const status = _.get(queriesState, ['status']); | ||
const isPending = get(queriesState, ['isPending']); | ||
const status = get(queriesState, ['status']); | ||
const hasSucceeded = status >= 200 && status < 300; | ||
@@ -142,3 +145,3 @@ | ||
if ( | ||
_.includes(config.retryableStatusCodes, resStatus) && | ||
includes(config.retryableStatusCodes, resStatus) && | ||
attempts < config.backoff.maxAttempts | ||
@@ -188,3 +191,3 @@ ) { | ||
url, | ||
transform = _.identity, | ||
transform = identity, | ||
update, | ||
@@ -191,0 +194,0 @@ queryKey: providedQueryKey, |
@@ -1,2 +0,2 @@ | ||
import _ from 'lodash'; | ||
import omit from 'lodash.omit'; | ||
@@ -24,3 +24,3 @@ import { | ||
} else { | ||
return _.omit(state, key); | ||
return omit(state, key); | ||
} | ||
@@ -27,0 +27,0 @@ }; |
@@ -1,3 +0,3 @@ | ||
import values from 'lodash/values'; | ||
import includes from 'lodash/includes'; | ||
import values from 'lodash.values'; | ||
import includes from 'lodash.includes'; | ||
@@ -4,0 +4,0 @@ import * as actionTypes from '../constants/action-types'; |
@@ -1,2 +0,2 @@ | ||
import _ from 'lodash'; | ||
import get from 'lodash.get'; | ||
@@ -6,19 +6,19 @@ import getQueryKey from '../lib/get-query-key'; | ||
export const isFinished = (url, body) => (queriesState) => { | ||
return _.get(queriesState, [getQueryKey(url, body), 'isFinished']); | ||
return get(queriesState, [getQueryKey(url, body), 'isFinished']); | ||
}; | ||
export const isPending = (url, body) => (queriesState) => { | ||
return _.get(queriesState, [getQueryKey(url, body), 'isPending']); | ||
return get(queriesState, [getQueryKey(url, body), 'isPending']); | ||
}; | ||
export const status = (url, body) => (queriesState) => { | ||
return _.get(queriesState, [getQueryKey(url, body), 'status']); | ||
return get(queriesState, [getQueryKey(url, body), 'status']); | ||
}; | ||
export const lastUpdated = (url, body) => (queriesState) => { | ||
return _.get(queriesState, [getQueryKey(url, body), 'lastUpdated']); | ||
return get(queriesState, [getQueryKey(url, body), 'lastUpdated']); | ||
}; | ||
export const queryCount = (url, body) => (queriesState) => { | ||
return _.get(queriesState, [getQueryKey(url, body), 'queryCount']); | ||
return get(queriesState, [getQueryKey(url, body), 'queryCount']); | ||
}; |
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
255
2%1
-50%205348
-15.34%15
66.67%2827
-3.68%4
300%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed