Comparing version 4.1.0 to 4.2.0
@@ -67,35 +67,30 @@ 'use strict'; | ||
// Helper that binds state to selectors. | ||
var bindStateSelectors = function bindStateSelectors(selectors, state) { | ||
return mapValues(selectors, function (selector) { | ||
return selector.bind(null, state); | ||
}); | ||
// HOC that binds state selectors and action creators. | ||
var connect = function connect(selectors, creators) { | ||
return !selectors || typeof selectors === "function" ? reactRedux.connect(selectors, mapDispatch(creators)) : reactRedux.connect(mapState(selectors), mapDispatch(creators)); | ||
}; | ||
// HOC that binds state selectors and action creators. | ||
var connect = function connect(selectors, creators) { | ||
// Bind action creators to dispatch. | ||
var bindCreators = function bindCreators(dispatch) { | ||
return mapValues(creators || {}, function (c) { | ||
return redux.bindActionCreators(c, dispatch); | ||
var mapState = function mapState(selectors) { | ||
return function (state) { | ||
return mapValues(selectors || {}, function (s) { | ||
return bindStateSelectors(s, state); | ||
}); | ||
}; | ||
}; | ||
// Use selectors directly if it's unset or mapStateToProps. | ||
if (!selectors || typeof selectors === "function") { | ||
return reactRedux.connect(selectors, bindCreators); | ||
} | ||
// Bind selectors to state if it's an object. | ||
var bindSelectors = function bindSelectors(state) { | ||
return mapValues(selectors, function (s) { | ||
return bindStateSelectors(s, state); | ||
var mapDispatch = function mapDispatch(creators) { | ||
return function (dispatch) { | ||
return mapValues(creators || {}, function (c) { | ||
return redux.bindActionCreators(c, dispatch); | ||
}); | ||
}; | ||
}; | ||
return reactRedux.connect(bindSelectors, bindCreators); | ||
var bindStateSelectors = function bindStateSelectors(selectors, state) { | ||
return mapValues(selectors, function (selector) { | ||
return selector.bind(null, state); | ||
}); | ||
}; | ||
exports.action = action; | ||
exports.bindStateSelectors = bindStateSelectors; | ||
exports.connect = connect; |
@@ -63,33 +63,29 @@ import { bindActionCreators } from 'redux'; | ||
// Helper that binds state to selectors. | ||
var bindStateSelectors = function bindStateSelectors(selectors, state) { | ||
return mapValues(selectors, function (selector) { | ||
return selector.bind(null, state); | ||
}); | ||
// HOC that binds state selectors and action creators. | ||
var connect$1 = function connect$$1(selectors, creators) { | ||
return !selectors || typeof selectors === "function" ? connect(selectors, mapDispatch(creators)) : connect(mapState(selectors), mapDispatch(creators)); | ||
}; | ||
// HOC that binds state selectors and action creators. | ||
var connect$1 = function connect$$1(selectors, creators) { | ||
// Bind action creators to dispatch. | ||
var bindCreators = function bindCreators(dispatch) { | ||
return mapValues(creators || {}, function (c) { | ||
return bindActionCreators(c, dispatch); | ||
var mapState = function mapState(selectors) { | ||
return function (state) { | ||
return mapValues(selectors || {}, function (s) { | ||
return bindStateSelectors(s, state); | ||
}); | ||
}; | ||
}; | ||
// Use selectors directly if it's unset or mapStateToProps. | ||
if (!selectors || typeof selectors === "function") { | ||
return connect(selectors, bindCreators); | ||
} | ||
// Bind selectors to state if it's an object. | ||
var bindSelectors = function bindSelectors(state) { | ||
return mapValues(selectors, function (s) { | ||
return bindStateSelectors(s, state); | ||
var mapDispatch = function mapDispatch(creators) { | ||
return function (dispatch) { | ||
return mapValues(creators || {}, function (c) { | ||
return bindActionCreators(c, dispatch); | ||
}); | ||
}; | ||
}; | ||
return connect(bindSelectors, bindCreators); | ||
var bindStateSelectors = function bindStateSelectors(selectors, state) { | ||
return mapValues(selectors, function (selector) { | ||
return selector.bind(null, state); | ||
}); | ||
}; | ||
export { action, bindStateSelectors, connect$1 as connect }; | ||
export { action, connect$1 as connect }; |
@@ -1,1 +0,1 @@ | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("redux"),require("react-redux")):"function"==typeof define&&define.amd?define(["exports","redux","react-redux"],e):e(n.inaction={},n.redux,n.reactRedux)}(this,function(n,r,u){"use strict";var o=function(e,t){var r={};return Object.keys(e).forEach(function(n){r[n]=t(e[n])}),r},i=function(n,e){return o(n,function(n){return n.bind(null,e)})};n.action=function(i,c){return function(o){return n=regeneratorRuntime.mark(function n(e,t){var r,u;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return r={type:i,payload:o},n.next=3,e(r);case 3:if(u=n.sent,!c){n.next=7;break}return n.next=7,c()(r,e,t);case 7:return n.abrupt("return",u);case 8:case"end":return n.stop()}},n,void 0)}),t=function(){var c=n.apply(this,arguments);return new Promise(function(o,i){return function e(n,t){try{var r=c[n](t),u=r.value}catch(n){return void i(n)}if(!r.done)return Promise.resolve(u).then(function(n){e("next",n)},function(n){e("throw",n)});o(u)}("next")})},function(n,e){return t.apply(this,arguments)};var n,t}},n.bindStateSelectors=i,n.connect=function(n,t){var e=function(e){return o(t||{},function(n){return r.bindActionCreators(n,e)})};if(!n||"function"==typeof n)return u.connect(n,e);return u.connect(function(e){return o(n,function(n){return i(n,e)})},e)},Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("redux"),require("react-redux")):"function"==typeof define&&define.amd?define(["exports","redux","react-redux"],e):e(n.inaction={},n.redux,n.reactRedux)}(this,function(n,t,r){"use strict";var u=function(e,t){var r={};return Object.keys(e).forEach(function(n){r[n]=t(e[n])}),r},o=function(n){return function(e){return u(n||{},function(n){return c(n,e)})}},i=function(n){return function(e){return u(n||{},function(n){return t.bindActionCreators(n,e)})}},c=function(n,e){return u(n,function(n){return n.bind(null,e)})};n.action=function(i,c){return function(o){return n=regeneratorRuntime.mark(function n(e,t){var r,u;return regeneratorRuntime.wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return r={type:i,payload:o},n.next=3,e(r);case 3:if(u=n.sent,!c){n.next=7;break}return n.next=7,c()(r,e,t);case 7:return n.abrupt("return",u);case 8:case"end":return n.stop()}},n,void 0)}),t=function(){var c=n.apply(this,arguments);return new Promise(function(o,i){return function e(n,t){try{var r=c[n](t),u=r.value}catch(n){return void i(n)}if(!r.done)return Promise.resolve(u).then(function(n){e("next",n)},function(n){e("throw",n)});o(u)}("next")})},function(n,e){return t.apply(this,arguments)};var n,t}},n.connect=function(n,e){return n&&"function"!=typeof n?r.connect(o(n),i(e)):r.connect(n,i(e))},Object.defineProperty(n,"__esModule",{value:!0})}); |
{ | ||
"name": "inaction", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"author": "olav", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
import { bindActionCreators } from "redux"; | ||
import { connect as reduxConnect } from "react-redux"; | ||
import { mapValues } from "./mapValues"; | ||
import { bindStateSelectors } from "./bindStateSelectors"; | ||
// HOC that binds state selectors and action creators. | ||
export const connect = (selectors, creators) => { | ||
// Bind action creators to dispatch. | ||
const bindCreators = dispatch => { | ||
return mapValues(creators || {}, c => bindActionCreators(c, dispatch)); | ||
}; | ||
return !selectors || typeof selectors === "function" | ||
? reduxConnect(selectors, mapDispatch(creators)) | ||
: reduxConnect(mapState(selectors), mapDispatch(creators)); | ||
}; | ||
// Use selectors directly if it's unset or mapStateToProps. | ||
if (!selectors || typeof selectors === "function") { | ||
return reduxConnect(selectors, bindCreators); | ||
} | ||
const mapState = selectors => state => { | ||
return mapValues(selectors || {}, s => bindStateSelectors(s, state)); | ||
}; | ||
// Bind selectors to state if it's an object. | ||
const bindSelectors = state => { | ||
return mapValues(selectors, s => bindStateSelectors(s, state)); | ||
}; | ||
const mapDispatch = creators => dispatch => { | ||
return mapValues(creators || {}, c => bindActionCreators(c, dispatch)); | ||
}; | ||
return reduxConnect(bindSelectors, bindCreators); | ||
const bindStateSelectors = (selectors, state) => { | ||
return mapValues(selectors, selector => selector.bind(null, state)); | ||
}; |
export * from "./action"; | ||
export * from "./bindStateSelectors"; | ||
export * from "./connect"; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12550
15
262