redux-zero
Advanced tools
Comparing version 5.0.5 to 5.1.0
# Changelog | ||
### 5.1.0 | ||
- Added hooks for react >= 16.8.0. The react bindings now offer a `useStore`, `useSelector` and `useAction` hooks. | ||
```jsx harmony | ||
const Counter = () => { | ||
const store = useStore() | ||
const count = useSelector(({ count }) => count) | ||
const incrementBy = useAction(({ count }, value) => ({ count: count + value})) | ||
return ( | ||
<> | ||
<p>Value: {count}</p> | ||
<button onClick={() => incrementBy(10)}>10 More</button> | ||
</> | ||
) | ||
} | ||
``` | ||
### 5.0.5 | ||
@@ -4,0 +24,0 @@ |
{ | ||
"name": "redux-zero", | ||
"version": "5.0.5", | ||
"version": "5.1.0", | ||
"description": "", | ||
@@ -60,6 +60,6 @@ "main": "dist/redux-zero.js", | ||
"@types/jest": "21.1.10", | ||
"@types/react": "16.0.9", | ||
"@types/react": "16.8.0", | ||
"cross-env": "5.0.5", | ||
"enzyme": "3.5.0", | ||
"enzyme-adapter-react-16": "1.2.0", | ||
"enzyme": "3.10.0", | ||
"enzyme-adapter-react-16": "1.14.0", | ||
"husky": "0.14.3", | ||
@@ -70,5 +70,5 @@ "jest": "21.2.1", | ||
"prettier": "1.12.0", | ||
"react": "16.0.0", | ||
"react-dom": "16.0.0", | ||
"react-test-renderer": "16.0.0", | ||
"react": "16.8.0", | ||
"react-dom": "16.8.0", | ||
"react-test-renderer": "16.8.0", | ||
"rimraf": "2.6.2", | ||
@@ -75,0 +75,0 @@ "rollup": "0.50.0", |
@@ -65,20 +65,21 @@ 'use strict'; | ||
function bindAction(action, store) { | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
if (typeof store.middleware === "function") { | ||
return store.middleware(store, action, args); | ||
} | ||
return set(store, action.apply(void 0, [store.getState()].concat(args))); | ||
}; | ||
} | ||
function bindActions(actions, store, ownProps) { | ||
actions = typeof actions === "function" ? actions(store, ownProps) : actions; | ||
var bound = {}; | ||
var _loop_1 = function (name_1) { | ||
bound[name_1] = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var action = actions[name_1]; | ||
if (typeof store.middleware === "function") { | ||
return store.middleware(store, action, args); | ||
} | ||
return set(store, action.apply(void 0, [store.getState()].concat(args))); | ||
}; | ||
}; | ||
for (var name_1 in actions) { | ||
_loop_1(name_1); | ||
var action = actions[name_1]; | ||
bound[name_1] = bindAction(action, store); | ||
} | ||
@@ -85,0 +86,0 @@ return bound; |
@@ -1,1 +0,1 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],n):n(t["redux-zero"]={},t.preact)}(this,function(t,i){"use strict";var r=function(t,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};function p(t,n){function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}var s=function(){return(s=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t}).apply(this,arguments)};function o(t,n){for(var e in t)if(t[e]!==n[e])return!1;for(var e in n)if(!(e in t))return!1;return!0}var u,n=(p(e,u=i.Component),e.prototype.componentWillMount=function(){this.unsubscribe=this.context.store.subscribe(this.update)},e.prototype.componentWillUnmount=function(){this.unsubscribe(this.update)},e.prototype.componentWillReceiveProps=function(t,n){var e=this.getProps(t,n);o(e,this.state)||this.setState(e)},e.prototype.getProps=function(t,n){var e=t.mapToProps,r=n.store&&n.store.getState()||{};return e?e(r,t):r},e.prototype.getActions=function(){return function(o,i,t){function n(r){e[r]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=o[r];return"function"==typeof i.middleware?i.middleware(i,e,t):function(t,n){if(null!=n){if(n.then)return n.then(t.setState);t.setState(n)}}(i,e.apply(void 0,[i.getState()].concat(t)))}}o="function"==typeof o?o(i,t):o;var e={};for(var r in o)n(r);return e}(this.props.actions,this.context.store,this.props)},e.prototype.render=function(t,n,e){var r=t.children,o=e.store;return(r&&r[0]||r)(s({store:o},n,this.actions))},e);function e(t,n){var e=u.call(this,t,n)||this;return e.update=function(){var t=e.getProps(e.props,e.context);o(t,e.state)||e.setState(t)},e.state=e.getProps(t,n),e.actions=e.getActions(),e}var c=n;var a,f=(p(h,a=i.Component),h.prototype.getChildContext=function(){return{store:this.props.store}},h.prototype.render=function(){return this.props.children&&this.props.children[0]||this.props.children},h);function h(){return null!==a&&a.apply(this,arguments)||this}t.connect=function(r,o){return void 0===o&&(o={}),function(e){return p(t,n=i.Component),t.prototype.render=function(){var n=this.props;return i.h(c,s({},n,{mapToProps:r,actions:o}),function(t){return i.h(e,s({},t,n))})},t;function t(){return null!==n&&n.apply(this,arguments)||this}var n}},t.Provider=f,t.Connect=n,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],n):n(t["redux-zero"]={},t.preact)}(this,function(t,i){"use strict";var r=function(t,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};function p(t,n){function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}var s=function(){return(s=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t}).apply(this,arguments)};function o(t,n){for(var e in t)if(t[e]!==n[e])return!1;for(var e in n)if(!(e in t))return!1;return!0}function u(e,r){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return"function"==typeof r.middleware?r.middleware(r,e,t):function(t,n){if(null!=n){if(n.then)return n.then(t.setState);t.setState(n)}}(r,e.apply(void 0,[r.getState()].concat(t)))}}var c,n=(p(e,c=i.Component),e.prototype.componentWillMount=function(){this.unsubscribe=this.context.store.subscribe(this.update)},e.prototype.componentWillUnmount=function(){this.unsubscribe(this.update)},e.prototype.componentWillReceiveProps=function(t,n){var e=this.getProps(t,n);o(e,this.state)||this.setState(e)},e.prototype.getProps=function(t,n){var e=t.mapToProps,r=n.store&&n.store.getState()||{};return e?e(r,t):r},e.prototype.getActions=function(){return function(t,n,e){t="function"==typeof t?t(n,e):t;var r={};for(var o in t){var i=t[o];r[o]=u(i,n)}return r}(this.props.actions,this.context.store,this.props)},e.prototype.render=function(t,n,e){var r=t.children,o=e.store;return(r&&r[0]||r)(s({store:o},n,this.actions))},e);function e(t,n){var e=c.call(this,t,n)||this;return e.update=function(){var t=e.getProps(e.props,e.context);o(t,e.state)||e.setState(t)},e.state=e.getProps(t,n),e.actions=e.getActions(),e}var a=n;var f,h=(p(l,f=i.Component),l.prototype.getChildContext=function(){return{store:this.props.store}},l.prototype.render=function(){return this.props.children&&this.props.children[0]||this.props.children},l);function l(){return null!==f&&f.apply(this,arguments)||this}t.connect=function(r,o){return void 0===o&&(o={}),function(e){return p(t,n=i.Component),t.prototype.render=function(){var n=this.props;return i.h(a,s({},n,{mapToProps:r,actions:o}),function(t){return i.h(e,s({},t,n))})},t;function t(){return null!==n&&n.apply(this,arguments)||this}var n}},t.Provider=h,t.Connect=n,Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -23,25 +23,54 @@ import * as React from "react"; | ||
export default function connect<S = any>(mapToProps?: mapToProps<S>, actions?: {}): (Child: any) => { | ||
new (props?: any, context?: any): { | ||
new (props: Readonly<any>): { | ||
render(): JSX.Element; | ||
setState<K extends never>(f: (prevState: {}, props: any) => Pick<{}, K>, callback?: () => any): void; | ||
setState<K extends never>(state: Pick<{}, K>, callback?: () => any): void; | ||
forceUpdate(callBack?: () => any): void; | ||
props: Readonly<{ | ||
context: any; | ||
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<any>) => {} | Pick<{}, K>) | Pick<{}, K>, callback?: () => void): void; | ||
forceUpdate(callBack?: () => void): void; | ||
readonly props: Readonly<{ | ||
children?: React.ReactNode; | ||
}> & Readonly<any>; | ||
state: Readonly<{}>; | ||
refs: { | ||
[key: string]: React.ReactInstance; | ||
}; | ||
componentDidMount?(): void; | ||
shouldComponentUpdate?(nextProps: Readonly<any>, nextState: Readonly<{}>, nextContext: any): boolean; | ||
componentWillUnmount?(): void; | ||
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void; | ||
getSnapshotBeforeUpdate?(prevProps: Readonly<any>, prevState: Readonly<{}>): any; | ||
componentDidUpdate?(prevProps: Readonly<any>, prevState: Readonly<{}>, snapshot?: any): void; | ||
componentWillMount?(): void; | ||
UNSAFE_componentWillMount?(): void; | ||
componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void; | ||
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void; | ||
componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<{}>, nextContext: any): void; | ||
UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<{}>, nextContext: any): void; | ||
}; | ||
new (props: any, context?: any): { | ||
render(): JSX.Element; | ||
context: any; | ||
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<any>) => {} | Pick<{}, K>) | Pick<{}, K>, callback?: () => void): void; | ||
forceUpdate(callBack?: () => void): void; | ||
readonly props: Readonly<{ | ||
children?: React.ReactNode; | ||
}> & Readonly<any>; | ||
state: Readonly<{}>; | ||
refs: { | ||
[key: string]: React.ReactInstance; | ||
}; | ||
componentWillMount?(): void; | ||
componentDidMount?(): void; | ||
componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void; | ||
shouldComponentUpdate?(nextProps: Readonly<any>, nextState: Readonly<{}>, nextContext: any): boolean; | ||
componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<{}>, nextContext: any): void; | ||
componentDidUpdate?(prevProps: Readonly<any>, prevState: Readonly<{}>, prevContext: any): void; | ||
componentWillUnmount?(): void; | ||
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void; | ||
getSnapshotBeforeUpdate?(prevProps: Readonly<any>, prevState: Readonly<{}>): any; | ||
componentDidUpdate?(prevProps: Readonly<any>, prevState: Readonly<{}>, snapshot?: any): void; | ||
componentWillMount?(): void; | ||
UNSAFE_componentWillMount?(): void; | ||
componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void; | ||
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void; | ||
componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<{}>, nextContext: any): void; | ||
UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<{}>, nextContext: any): void; | ||
}; | ||
contextType?: React.Context<any>; | ||
}; | ||
export {}; |
@@ -12,3 +12,3 @@ import * as React from "react"; | ||
}; | ||
render(): React.ReactElement<any>; | ||
render(): JSX.Element; | ||
} |
import connect, { Connect } from "./components/connect"; | ||
import Provider from "./components/Provider"; | ||
export { connect, Provider, Connect }; | ||
import { useStore } from "./hooks/useStore"; | ||
import { useSelector } from "./hooks/useSelector"; | ||
import { useAction } from "./hooks/useAction"; | ||
export { connect, Provider, Connect, useStore, useSelector, useAction }; |
@@ -72,20 +72,21 @@ 'use strict'; | ||
function bindAction(action, store) { | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
if (typeof store.middleware === "function") { | ||
return store.middleware(store, action, args); | ||
} | ||
return set(store, action.apply(void 0, [store.getState()].concat(args))); | ||
}; | ||
} | ||
function bindActions(actions, store, ownProps) { | ||
actions = typeof actions === "function" ? actions(store, ownProps) : actions; | ||
var bound = {}; | ||
var _loop_1 = function (name_1) { | ||
bound[name_1] = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var action = actions[name_1]; | ||
if (typeof store.middleware === "function") { | ||
return store.middleware(store, action, args); | ||
} | ||
return set(store, action.apply(void 0, [store.getState()].concat(args))); | ||
}; | ||
}; | ||
for (var name_1 in actions) { | ||
_loop_1(name_1); | ||
var action = actions[name_1]; | ||
bound[name_1] = bindAction(action, store); | ||
} | ||
@@ -150,2 +151,16 @@ return bound; | ||
var Context; | ||
if ("createContext" in React) { | ||
Context = React.createContext(undefined); | ||
} | ||
else { | ||
Context = { | ||
Provider: function (_a) { | ||
var children = _a.children; | ||
return React.Children.only(children); | ||
} | ||
}; | ||
} | ||
var Context$1 = Context; | ||
var Provider = /** @class */ (function (_super) { | ||
@@ -161,4 +176,4 @@ __extends(Provider, _super); | ||
Provider.prototype.render = function () { | ||
var children = this.props.children; | ||
return React.Children.only(children); | ||
var _a = this.props, store = _a.store, children = _a.children; | ||
return React.createElement(Context$1.Provider, { value: store }, children); | ||
}; | ||
@@ -171,4 +186,70 @@ Provider.childContextTypes = { | ||
function useStore() { | ||
return React.useContext(Context$1); | ||
} | ||
// Heavily inspired by the react-redux implementation | ||
// https://github.com/reduxjs/react-redux/blob/master/src/hooks/useSelector.js | ||
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect; | ||
function useSelector(selector) { | ||
var store = useStore(); | ||
var _a = React.useReducer(function (s) { return s + 1; }, 0), forceRerender = _a[1]; | ||
var selectorRef = React.useRef(undefined); | ||
var selectedStateRef = React.useRef(undefined); | ||
var onChangeErrorRef = React.useRef(undefined); | ||
var selectedState; | ||
try { | ||
if (selectorRef.current !== selector || onChangeErrorRef.current) { | ||
selectedState = selector(store.getState()); | ||
} | ||
else { | ||
selectedState = selectedStateRef.current; | ||
} | ||
} | ||
catch (err) { | ||
var errorMessage = "An error occurred while selecting the store state: " + err.message + "."; | ||
if (onChangeErrorRef.current) { | ||
errorMessage += | ||
"\nThe error may be related with this previous error:\n" + onChangeErrorRef.current.stack + "\n\nOriginal stack trace:"; | ||
} | ||
throw new Error(errorMessage); | ||
} | ||
useIsomorphicLayoutEffect(function () { | ||
selectorRef.current = selector; | ||
selectedStateRef.current = selectedState; | ||
onChangeErrorRef.current = undefined; | ||
}); | ||
useIsomorphicLayoutEffect(function () { | ||
var checkForUpdates = function () { | ||
try { | ||
var newSelectedState = selectorRef.current(store.getState()); | ||
if (newSelectedState === selectedStateRef.current) { | ||
return; | ||
} | ||
selectedStateRef.current = newSelectedState; | ||
} | ||
catch (err) { | ||
onChangeErrorRef.current = err; | ||
} | ||
forceRerender({}); | ||
}; | ||
var unsubscribe = store.subscribe(checkForUpdates); | ||
checkForUpdates(); | ||
return function () { return unsubscribe(); }; | ||
}, [store]); | ||
return selectedState; | ||
} | ||
function useAction(action) { | ||
var store = useStore(); | ||
return React.useMemo(function () { | ||
return bindAction(action, store); | ||
}, [store, action]); | ||
} | ||
exports.connect = connect; | ||
exports.Provider = Provider; | ||
exports.Connect = Connect; | ||
exports.useStore = useStore; | ||
exports.useSelector = useSelector; | ||
exports.useAction = useAction; |
@@ -1,1 +0,1 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],n):n(t["redux-zero"]={},t.React)}(this,function(t,i){"use strict";var o=function(t,n){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};function p(t,n){function e(){this.constructor=t}o(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}var s=function(){return(s=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++)for(var r in n=arguments[e])Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);return t}).apply(this,arguments)};function n(t,n,e){return"object"==typeof t?null:new Error("Invalid prop "+n+" supplied to "+e)}var e,u=(p(r,e=i.Component),r.prototype.componentWillMount=function(){this.unsubscribe=this.context.store.subscribe(this.update)},r.prototype.componentWillUnmount=function(){this.unsubscribe(this.update)},r.prototype.getProps=function(){var t=this.props.mapToProps,n=this.context.store&&this.context.store.getState()||{};return t?t(n,this.props):n},r.prototype.getActions=function(){return function(r,i,t){function n(o){e[o]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=r[o];return"function"==typeof i.middleware?i.middleware(i,e,t):function(t,n){if(null!=n){if(n.then)return n.then(t.setState);t.setState(n)}}(i,e.apply(void 0,[i.getState()].concat(t)))}}r="function"==typeof r?r(i,t):r;var e={};for(var o in r)n(o);return e}(this.props.actions,this.context.store,this.props)},r.prototype.render=function(){return this.props.children(s({store:this.context.store},this.state,this.actions))},r.contextTypes={store:n},r);function r(){var n=null!==e&&e.apply(this,arguments)||this;return n.state=n.getProps(),n.actions=n.getActions(),n.update=function(){var t=n.getProps();!function(t,n){for(var e in t)if(t[e]!==n[e])return!1;for(var e in n)if(!(e in t))return!1;return!0}(t,n.state)&&n.setState(t)},n}var c,a=(p(f,c=i.Component),f.prototype.getChildContext=function(){return{store:this.props.store}},f.prototype.render=function(){var t=this.props.children;return i.Children.only(t)},f.childContextTypes={store:n},f);function f(){return null!==c&&c.apply(this,arguments)||this}t.connect=function(o,r){return void 0===r&&(r={}),function(e){return p(t,n=i.Component),t.prototype.render=function(){var n=this.props;return i.createElement(u,s({},n,{mapToProps:o,actions:r}),function(t){return i.createElement(e,s({},t,n))})},t;function t(){return null!==n&&n.apply(this,arguments)||this}var n}},t.Provider=a,t.Connect=u,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e(t["redux-zero"]={},t.React)}(this,function(t,s){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function i(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var u=function(){return(u=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function e(t,e,r){return"object"==typeof t?null:new Error("Invalid prop "+e+" supplied to "+r)}function c(r,n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"function"==typeof n.middleware?n.middleware(n,r,t):function(t,e){if(null!=e){if(e.then)return e.then(t.setState);t.setState(e)}}(n,r.apply(void 0,[n.getState()].concat(t)))}}var r,p=(i(o,r=s.Component),o.prototype.componentWillMount=function(){this.unsubscribe=this.context.store.subscribe(this.update)},o.prototype.componentWillUnmount=function(){this.unsubscribe(this.update)},o.prototype.getProps=function(){var t=this.props.mapToProps,e=this.context.store&&this.context.store.getState()||{};return t?t(e,this.props):e},o.prototype.getActions=function(){return function(t,e,r){t="function"==typeof t?t(e,r):t;var n={};for(var o in t){var i=t[o];n[o]=c(i,e)}return n}(this.props.actions,this.context.store,this.props)},o.prototype.render=function(){return this.props.children(u({store:this.context.store},this.state,this.actions))},o.contextTypes={store:e},o);function o(){var e=null!==r&&r.apply(this,arguments)||this;return e.state=e.getProps(),e.actions=e.getActions(),e.update=function(){var t=e.getProps();!function(t,e){for(var r in t)if(t[r]!==e[r])return!1;for(var r in e)if(!(r in t))return!1;return!0}(t,e.state)&&e.setState(t)},e}var a,f="createContext"in s?s.createContext(void 0):{Provider:function(t){var e=t.children;return s.Children.only(e)}},h=(i(l,a=s.Component),l.prototype.getChildContext=function(){return{store:this.props.store}},l.prototype.render=function(){var t=this.props,e=t.store,r=t.children;return s.createElement(f.Provider,{value:e},r)},l.childContextTypes={store:e},l);function l(){return null!==a&&a.apply(this,arguments)||this}function d(){return s.useContext(f)}var v="undefined"!=typeof window?s.useLayoutEffect:s.useEffect;t.connect=function(n,o){return void 0===o&&(o={}),function(r){return i(t,e=s.Component),t.prototype.render=function(){var e=this.props;return s.createElement(p,u({},e,{mapToProps:n,actions:o}),function(t){return s.createElement(r,u({},t,e))})},t;function t(){return null!==e&&e.apply(this,arguments)||this}var e}},t.Provider=h,t.Connect=p,t.useStore=d,t.useSelector=function(t){var e,r=d(),n=s.useReducer(function(t){return t+1},0)[1],o=s.useRef(void 0),i=s.useRef(void 0),u=s.useRef(void 0);try{e=o.current!==t||u.current?t(r.getState()):i.current}catch(t){var c="An error occurred while selecting the store state: "+t.message+".";throw u.current&&(c+="\nThe error may be related with this previous error:\n"+u.current.stack+"\n\nOriginal stack trace:"),new Error(c)}return v(function(){o.current=t,i.current=e,u.current=void 0}),v(function(){function t(){try{var t=o.current(r.getState());if(t===i.current)return;i.current=t}catch(t){u.current=t}n({})}var e=r.subscribe(t);return t(),function(){return e()}},[r]),e},t.useAction=function(t){var e=d();return s.useMemo(function(){return c(t,e)},[e,t])},Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -79,20 +79,21 @@ 'use strict'; | ||
function bindAction(action, store) { | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
if (typeof store.middleware === "function") { | ||
return store.middleware(store, action, args); | ||
} | ||
return set(store, action.apply(void 0, [store.getState()].concat(args))); | ||
}; | ||
} | ||
function bindActions(actions, store, ownProps) { | ||
actions = typeof actions === "function" ? actions(store, ownProps) : actions; | ||
var bound = {}; | ||
var _loop_1 = function (name_1) { | ||
bound[name_1] = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var action = actions[name_1]; | ||
if (typeof store.middleware === "function") { | ||
return store.middleware(store, action, args); | ||
} | ||
return set(store, action.apply(void 0, [store.getState()].concat(args))); | ||
}; | ||
}; | ||
for (var name_1 in actions) { | ||
_loop_1(name_1); | ||
var action = actions[name_1]; | ||
bound[name_1] = bindAction(action, store); | ||
} | ||
@@ -99,0 +100,0 @@ return bound; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t["redux-zero"]={})}(this,function(t){"use strict";var u=function(){return(u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};t.connect=function(n,r,o){function t(){var t=function(t,e){var n,r,o={},f=!1;for(var i in t){var c=t[i];((n=e[i])!==(r=c)||n&&"object"==typeof n&&!function(t,e){for(var n in t)if(t[n]!==e[n])return!1;for(var n in e)if(!(n in t))return!1;return!0}(n,r))&&(f=!0,"object"==typeof c&&"function"!=typeof c.getMonth?o[i]=c.constructor===Array?c.slice(0):u({},c):o[i]=c)}return{diff:o,changed:f}}(o(r.getState()),n.get()),e=t.diff;t.changed&&n.set(e)}t(),n.on("destroy",r.subscribe(t))},t.getActions=function(t,e){return function(o,f,t){function e(r){n[r]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=o[r];return"function"==typeof f.middleware?f.middleware(f,n,t):function(t,e){if(null!=e){if(e.then)return e.then(t.setState);t.setState(e)}}(f,n.apply(void 0,[f.getState()].concat(t)))}}o="function"==typeof o?o(f,t):o;var n={};for(var r in o)e(r);return n}(e,t)},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t["redux-zero"]={})}(this,function(t){"use strict";var c=function(){return(c=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function i(n,r){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"function"==typeof r.middleware?r.middleware(r,n,t):function(t,e){if(null!=e){if(e.then)return e.then(t.setState);t.setState(e)}}(r,n.apply(void 0,[r.getState()].concat(t)))}}t.connect=function(n,r,o){function t(){var t=function(t,e){var n,r,o={},f=!1;for(var i in t){var u=t[i];((n=e[i])!==(r=u)||n&&"object"==typeof n&&!function(t,e){for(var n in t)if(t[n]!==e[n])return!1;for(var n in e)if(!(n in t))return!1;return!0}(n,r))&&(f=!0,"object"==typeof u&&"function"!=typeof u.getMonth?o[i]=u.constructor===Array?u.slice(0):c({},u):o[i]=u)}return{diff:o,changed:f}}(o(r.getState()),n.get()),e=t.diff;t.changed&&n.set(e)}t(),n.on("destroy",r.subscribe(t))},t.getActions=function(t,e){return function(t,e,n){t="function"==typeof t?t(e,n):t;var r={};for(var o in t){var f=t[o];r[o]=i(f,e)}return r}(e,t)},Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -13,20 +13,21 @@ 'use strict'; | ||
function bindAction(action, store) { | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
if (typeof store.middleware === "function") { | ||
return store.middleware(store, action, args); | ||
} | ||
return set(store, action.apply(void 0, [store.getState()].concat(args))); | ||
}; | ||
} | ||
function bindActions(actions, store, ownProps) { | ||
actions = typeof actions === "function" ? actions(store, ownProps) : actions; | ||
var bound = {}; | ||
var _loop_1 = function (name_1) { | ||
bound[name_1] = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var action = actions[name_1]; | ||
if (typeof store.middleware === "function") { | ||
return store.middleware(store, action, args); | ||
} | ||
return set(store, action.apply(void 0, [store.getState()].concat(args))); | ||
}; | ||
}; | ||
for (var name_1 in actions) { | ||
_loop_1(name_1); | ||
var action = actions[name_1]; | ||
bound[name_1] = bindAction(action, store); | ||
} | ||
@@ -33,0 +34,0 @@ return bound; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t["redux-zero"]={})}(this,function(t){"use strict";var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};t.bindActions=function(o,i,t){function e(r){n[r]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=o[r];return"function"==typeof i.middleware?i.middleware(i,n,t):function(t,e){if(null!=e){if(e.then)return e.then(t.setState);t.setState(e)}}(i,n.apply(void 0,[i.getState()].concat(t)))}}o="function"==typeof o?o(i,t):o;var n={};for(var r in o)e(r);return n},t.combineActions=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e.reduce(function(t,e){return r({},t,"function"==typeof e?e.apply(void 0,n):e)},{})}},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t["redux-zero"]={})}(this,function(t){"use strict";function f(n,r){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"function"==typeof r.middleware?r.middleware(r,n,t):function(t,e){if(null!=e){if(e.then)return e.then(t.setState);t.setState(e)}}(r,n.apply(void 0,[r.getState()].concat(t)))}}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};t.bindActions=function(t,e,n){t="function"==typeof t?t(e,n):t;var r={};for(var o in t){var i=t[o];r[o]=f(i,e)}return r},t.combineActions=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];return e.reduce(function(t,e){return r({},t,"function"==typeof e?e.apply(void 0,n):e)},{})}},Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -79,20 +79,21 @@ 'use strict'; | ||
function bindAction(action, store) { | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
if (typeof store.middleware === "function") { | ||
return store.middleware(store, action, args); | ||
} | ||
return set(store, action.apply(void 0, [store.getState()].concat(args))); | ||
}; | ||
} | ||
function bindActions(actions, store, ownProps) { | ||
actions = typeof actions === "function" ? actions(store, ownProps) : actions; | ||
var bound = {}; | ||
var _loop_1 = function (name_1) { | ||
bound[name_1] = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var action = actions[name_1]; | ||
if (typeof store.middleware === "function") { | ||
return store.middleware(store, action, args); | ||
} | ||
return set(store, action.apply(void 0, [store.getState()].concat(args))); | ||
}; | ||
}; | ||
for (var name_1 in actions) { | ||
_loop_1(name_1); | ||
var action = actions[name_1]; | ||
bound[name_1] = bindAction(action, store); | ||
} | ||
@@ -99,0 +100,0 @@ return bound; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t["redux-zero"]={})}(this,function(t){"use strict";var u=function(){return(u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};t.connect=function(n,r,o,t){c();var e=n.beforeDestroy,f=r.subscribe(c);function i(t,e){for(var n in t)e[n]=t[n]}function c(){var t=function(t,e){var n,r,o={},f=!1;for(var i in t){var c=t[i];((n=e[i])!==(r=c)||n&&"object"==typeof n&&!function(t,e){for(var n in t)if(t[n]!==e[n])return!1;for(var n in e)if(!(n in t))return!1;return!0}(n,r))&&(f=!0,"object"==typeof c&&"function"!=typeof c.getMonth?o[i]=c.constructor===Array?c.slice(0):u({},c):o[i]=c)}return{diff:o,changed:f}}(o(r.getState()),o(n)),e=t.diff;t.changed&&i(e,n)}n.beforeDestroy=function(){f(),e()},i(function(o,f,t){function e(r){n[r]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=o[r];return"function"==typeof f.middleware?f.middleware(f,n,t):function(t,e){if(null!=e){if(e.then)return e.then(t.setState);t.setState(e)}}(f,n.apply(void 0,[f.getState()].concat(t)))}}o="function"==typeof o?o(f,t):o;var n={};for(var r in o)e(r);return n}(t,r),n)},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t["redux-zero"]={})}(this,function(t){"use strict";var c=function(){return(c=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function a(n,r){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return"function"==typeof r.middleware?r.middleware(r,n,t):function(t,e){if(null!=e){if(e.then)return e.then(t.setState);t.setState(e)}}(r,n.apply(void 0,[r.getState()].concat(t)))}}t.connect=function(n,r,o,t){u();var e=n.beforeDestroy,f=r.subscribe(u);function i(t,e){for(var n in t)e[n]=t[n]}function u(){var t=function(t,e){var n,r,o={},f=!1;for(var i in t){var u=t[i];((n=e[i])!==(r=u)||n&&"object"==typeof n&&!function(t,e){for(var n in t)if(t[n]!==e[n])return!1;for(var n in e)if(!(n in t))return!1;return!0}(n,r))&&(f=!0,"object"==typeof u&&"function"!=typeof u.getMonth?o[i]=u.constructor===Array?u.slice(0):c({},u):o[i]=u)}return{diff:o,changed:f}}(o(r.getState()),o(n)),e=t.diff;t.changed&&i(e,n)}n.beforeDestroy=function(){f(),e()},i(function(t,e,n){t="function"==typeof t?t(e,n):t;var r={};for(var o in t){var f=t[o];r[o]=a(f,e)}return r}(t,r),n)},Object.defineProperty(t,"__esModule",{value:!0})}); |
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
77799
50
1145