redux-zero
Advanced tools
Comparing version 2.1.3 to 3.0.0
# Changelog | ||
### 3.0.0 | ||
- Removing `unsubscribe` function from createStore. Now `subscribe` returns `unsubscribe`: | ||
```javascript | ||
const store = createStore() | ||
const unsubscribe = store.subscribe() | ||
unsubscribe() | ||
``` | ||
### 2.1.0 | ||
@@ -4,0 +16,0 @@ |
@@ -5,2 +5,3 @@ /// <reference types="react" /> | ||
new (props?: {}, context?: any): { | ||
unsubscribe: any; | ||
state: any; | ||
@@ -7,0 +8,0 @@ componentWillMount(): void; |
@@ -53,9 +53,6 @@ 'use strict'; | ||
listeners.push(f); | ||
return function () { | ||
listeners.splice(listeners.indexOf(f)); | ||
}; | ||
}, | ||
unsubscribe: function (f) { | ||
var i = listeners.indexOf(f); | ||
if (i > -1) { | ||
listeners.splice(i, 1); | ||
} | ||
}, | ||
getState: function () { | ||
@@ -99,6 +96,6 @@ return state; | ||
Connected.prototype.componentWillMount = function () { | ||
this.context.store.subscribe(this.update); | ||
this.unsubscribe = this.context.store.subscribe(this.update); | ||
}; | ||
Connected.prototype.componentWillUnmount = function () { | ||
this.context.store.unsubscribe(this.update); | ||
this.unsubscribe(this.update); | ||
}; | ||
@@ -105,0 +102,0 @@ Connected.prototype.getProps = function () { |
@@ -49,9 +49,6 @@ import { Children, Component, createElement } from 'react'; | ||
listeners.push(f); | ||
return function () { | ||
listeners.splice(listeners.indexOf(f)); | ||
}; | ||
}, | ||
unsubscribe: function (f) { | ||
var i = listeners.indexOf(f); | ||
if (i > -1) { | ||
listeners.splice(i, 1); | ||
} | ||
}, | ||
getState: function () { | ||
@@ -95,6 +92,6 @@ return state; | ||
Connected.prototype.componentWillMount = function () { | ||
this.context.store.subscribe(this.update); | ||
this.unsubscribe = this.context.store.subscribe(this.update); | ||
}; | ||
Connected.prototype.componentWillUnmount = function () { | ||
this.context.store.unsubscribe(this.update); | ||
this.unsubscribe(this.update); | ||
}; | ||
@@ -101,0 +98,0 @@ Connected.prototype.getProps = function () { |
@@ -1,2 +0,2 @@ | ||
!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,e){"use strict";function n(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function r(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}function o(t,e,n){return"object"==typeof t?null:new Error("Invalid prop "+e+" supplied to "+n)}var i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},c=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return n(r,t),r.prototype.getChildContext=function(){return{store:this.props.store}},r.prototype.render=function(){var t=this.props.children;return e.Children.only(t)},r.childContextTypes={store:o},r}(e.Component);t.createStore=function(t){void 0===t&&(t={});var e=[];return{setState:function(n){t="function"==typeof n?u({},t,n(t)):u({},t,n),e.forEach(function(e){return e(t)})},subscribe:function(t){e.push(t)},unsubscribe:function(t){var n=e.indexOf(t);n>-1&&e.splice(n,1)},getState:function(){return t}}},t.connect=function(t){return function(i){return c=function(o){function c(){var t=null!==o&&o.apply(this,arguments)||this;return t.state=t.getProps(),t.update=function(){var e=t.getProps();r(e,t.state)||t.setState(e)},t}return n(c,o),c.prototype.componentWillMount=function(){this.context.store.subscribe(this.update)},c.prototype.componentWillUnmount=function(){this.context.store.unsubscribe(this.update)},c.prototype.getProps=function(){var e=this.context.store&&this.context.store.getState()||{};return t(e,this.props)},c.prototype.render=function(){return e.createElement(i,u({store:this.context.store},this.props,this.state))},c}(e.Component),c.contextTypes={store:o},c;var c}},t.Provider=c,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,e){"use strict";function n(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function r(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}function o(t,e,n){return"object"==typeof t?null:new Error("Invalid prop "+e+" supplied to "+n)}var i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},s=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return n(r,t),r.prototype.getChildContext=function(){return{store:this.props.store}},r.prototype.render=function(){var t=this.props.children;return e.Children.only(t)},r.childContextTypes={store:o},r}(e.Component);t.createStore=function(t){void 0===t&&(t={});var e=[];return{setState:function(n){t="function"==typeof n?u({},t,n(t)):u({},t,n),e.forEach(function(e){return e(t)})},subscribe:function(t){return e.push(t),function(){e.splice(e.indexOf(t))}},getState:function(){return t}}},t.connect=function(t){return function(i){return s=function(o){function s(){var t=null!==o&&o.apply(this,arguments)||this;return t.state=t.getProps(),t.update=function(){var e=t.getProps();r(e,t.state)||t.setState(e)},t}return n(s,o),s.prototype.componentWillMount=function(){this.unsubscribe=this.context.store.subscribe(this.update)},s.prototype.componentWillUnmount=function(){this.unsubscribe(this.update)},s.prototype.getProps=function(){var e=this.context.store&&this.context.store.getState()||{};return t(e,this.props)},s.prototype.render=function(){return e.createElement(i,u({store:this.context.store},this.props,this.state))},s}(e.Component),s.contextTypes={store:o},s;var s}},t.Provider=s,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=redux-zero.min.js.map |
export default function createStore(state?: {}): { | ||
setState(update: any): void; | ||
subscribe(f: any): void; | ||
unsubscribe(f: any): void; | ||
subscribe(f: any): () => void; | ||
getState(): {}; | ||
}; |
### License | ||
The MIT License (MIT) | ||
Copyright (c) <year> <copyright holders> | ||
Copyright (c) <2017> <Matheus Lima (matheusml90@gmail.com)> | ||
@@ -6,0 +6,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
{ | ||
"name": "redux-zero", | ||
"version": "2.1.3", | ||
"version": "3.0.0", | ||
"description": "", | ||
@@ -24,3 +24,6 @@ "main": "dist/redux-zero.cjs.js", | ||
"author": "Matheus Lima <matheusml90@gmail.com>", | ||
"files": ["dist", "typings"], | ||
"files": [ | ||
"dist", | ||
"typings" | ||
], | ||
"license": "MIT", | ||
@@ -27,0 +30,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
36724
318