redux-persist
Advanced tools
Comparing version 5.2.2 to 5.3.0-rc
@@ -12,4 +12,4 @@ import { DEFAULT_VERSION } from './constants'; | ||
} | ||
// this is gauranteed to exist as version gets added before any state is stored | ||
var inboundVersion = state._persist.version; | ||
var inboundVersion = state._persist && state._persist.version !== undefined ? state._persist.version : DEFAULT_VERSION; | ||
if (inboundVersion === currentVersion) { | ||
@@ -16,0 +16,0 @@ if (process.env.NODE_ENV !== 'production' && debug) console.log('redux-persist: versions match, noop migration'); |
@@ -36,4 +36,11 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
if (bootstrapped) { | ||
_this.props.onBeforeLift && _this.props.onBeforeLift(); | ||
_this.setState({ bootstrapped: true }); | ||
if (_this.props.onBeforeLift) { | ||
Promise.resolve(_this.props.onBeforeLift()).then(function () { | ||
return _this.setState({ bootstrapped: true }); | ||
}).catch(function () { | ||
return _this.setState({ bootstrapped: true }); | ||
}); | ||
} else { | ||
_this.setState({ bootstrapped: true }); | ||
} | ||
_this._unsubscribe && _this._unsubscribe(); | ||
@@ -40,0 +47,0 @@ } |
@@ -38,4 +38,9 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
} | ||
// otherwise shallow merge the new values (hence "Level2") | ||
newState[key] = _extends({}, newState[key], inboundState[key]); | ||
if (!isPlainEnoughObject(reducedState[key])) { | ||
// if object is plain enough shallow merge the new values (hence "Level2") | ||
newState[key] = _extends({}, newState[key], inboundState[key]); | ||
return; | ||
} | ||
// otherwise hard set | ||
newState[key] = inboundState[key]; | ||
}); | ||
@@ -54,2 +59,6 @@ } | ||
- this is essentially redux-perist v4 behavior | ||
*/ | ||
*/ | ||
function isPlainEnoughObject(o) { | ||
return o !== null && !Array.isArray(o) && (typeof o === 'undefined' ? 'undefined' : _typeof(o)) === 'object'; | ||
} |
@@ -17,4 +17,4 @@ 'use strict'; | ||
} | ||
// this is gauranteed to exist as version gets added before any state is stored | ||
var inboundVersion = state._persist.version; | ||
var inboundVersion = state._persist && state._persist.version !== undefined ? state._persist.version : _constants.DEFAULT_VERSION; | ||
if (inboundVersion === currentVersion) { | ||
@@ -21,0 +21,0 @@ if (process.env.NODE_ENV !== 'production' && debug) console.log('redux-persist: versions match, noop migration'); |
@@ -45,4 +45,11 @@ 'use strict'; | ||
if (bootstrapped) { | ||
_this.props.onBeforeLift && _this.props.onBeforeLift(); | ||
_this.setState({ bootstrapped: true }); | ||
if (_this.props.onBeforeLift) { | ||
Promise.resolve(_this.props.onBeforeLift()).then(function () { | ||
return _this.setState({ bootstrapped: true }); | ||
}).catch(function () { | ||
return _this.setState({ bootstrapped: true }); | ||
}); | ||
} else { | ||
_this.setState({ bootstrapped: true }); | ||
} | ||
_this._unsubscribe && _this._unsubscribe(); | ||
@@ -49,0 +56,0 @@ } |
@@ -43,4 +43,9 @@ 'use strict'; | ||
} | ||
// otherwise shallow merge the new values (hence "Level2") | ||
newState[key] = _extends({}, newState[key], inboundState[key]); | ||
if (!isPlainEnoughObject(reducedState[key])) { | ||
// if object is plain enough shallow merge the new values (hence "Level2") | ||
newState[key] = _extends({}, newState[key], inboundState[key]); | ||
return; | ||
} | ||
// otherwise hard set | ||
newState[key] = inboundState[key]; | ||
}); | ||
@@ -59,2 +64,6 @@ } | ||
- this is essentially redux-perist v4 behavior | ||
*/ | ||
*/ | ||
function isPlainEnoughObject(o) { | ||
return o !== null && !Array.isArray(o) && (typeof o === 'undefined' ? 'undefined' : _typeof(o)) === 'object'; | ||
} |
{ | ||
"name": "redux-persist", | ||
"version": "5.2.2", | ||
"version": "5.3.0-rc", | ||
"description": "persist and rehydrate redux stores", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -19,3 +19,3 @@ # Redux Persist | ||
import storage from 'redux-persist/es/storage' // default: localStorage if web, AsyncStorage if react-native | ||
import reducers from './reducers' // where reducers is a object of reducers | ||
import reducers from './reducers' // where reducers is an object of reducers | ||
@@ -59,3 +59,3 @@ const config = { | ||
There are three important breaking changes. | ||
1. api has changed as described in the above migration section | ||
1. api has changed as described in the [migration](#migration-from-v4-to-v5) section below. | ||
2. state with cycles is no longer serialized using json-stringify-safe, and will instead noop. | ||
@@ -62,0 +62,0 @@ 3. state methods can no longer be overridden which means all top level state needs to be plain objects. `redux-persist-transform-immutable` will continue to operate as before as it works on substate, not top level state. |
@@ -21,4 +21,7 @@ // @flow | ||
} | ||
// this is gauranteed to exist as version gets added before any state is stored | ||
let inboundVersion: number = state._persist.version | ||
let inboundVersion: number = | ||
state._persist && state._persist.version !== undefined | ||
? state._persist.version | ||
: DEFAULT_VERSION | ||
if (inboundVersion === currentVersion) { | ||
@@ -25,0 +28,0 @@ if (process.env.NODE_ENV !== 'production' && debug) |
@@ -38,4 +38,9 @@ // @flow | ||
if (bootstrapped) { | ||
this.props.onBeforeLift && this.props.onBeforeLift() | ||
this.setState({ bootstrapped: true }) | ||
if (this.props.onBeforeLift) { | ||
Promise.resolve(this.props.onBeforeLift()) | ||
.then(() => this.setState({ bootstrapped: true })) | ||
.catch(() => this.setState({ bootstrapped: true })) | ||
} else { | ||
this.setState({ bootstrapped: true }) | ||
} | ||
this._unsubscribe && this._unsubscribe() | ||
@@ -42,0 +47,0 @@ } |
@@ -77,4 +77,9 @@ // @flow | ||
} | ||
// otherwise shallow merge the new values (hence "Level2") | ||
newState[key] = { ...newState[key], ...inboundState[key] } | ||
if (!isPlainEnoughObject(reducedState[key])) { | ||
// if object is plain enough shallow merge the new values (hence "Level2") | ||
newState[key] = { ...newState[key], ...inboundState[key] } | ||
return | ||
} | ||
// otherwise hard set | ||
newState[key] = inboundState[key] | ||
}) | ||
@@ -97,1 +102,5 @@ } | ||
} | ||
function isPlainEnoughObject(o) { | ||
return o !== null && !Array.isArray(o) && typeof o === 'object' | ||
} |
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
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
195382
2741
2