Socket
Socket
Sign inDemoInstall

redux-persist

Package Overview
Dependencies
1
Maintainers
2
Versions
186
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.0-rc.5 to 5.0.0-rc.6

1

es/constants.js
export var KEY_PREFIX = 'persist:';
export var FLUSH = 'persist/FLUSH';
export var REHYDRATE = 'persist/REHYDRATE';
export var PAUSE = 'persist/PAUSE';
export var PERSIST = 'persist/PERSIST';

@@ -5,0 +6,0 @@ export var PURGE = 'persist/PURGE';

18

es/persistReducer.js

@@ -7,3 +7,3 @@ 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; };

import { FLUSH, PERSIST, PURGE, REHYDRATE, DEFAULT_VERSION } from './constants';
import { FLUSH, PAUSE, PERSIST, PURGE, REHYDRATE, DEFAULT_VERSION } from './constants';

@@ -33,2 +33,3 @@ import stateReconciler from './stateReconciler';

var _purge = false;
var _paused = true;

@@ -50,2 +51,5 @@ if (process.env.NODE_ENV !== 'production') {

if (action.type === PERSIST) {
// @NOTE PERSIST resumes if paused.
_paused = false;
// @NOTE only ever create persistoid once, ensure we call it at least once, even if _persist has already been set

@@ -88,2 +92,4 @@ if (!_persistoid) _persistoid = createPersistoid(config);

});
} else if (action.type === PAUSE) {
_paused = true;
} else if (action.type === REHYDRATE) {

@@ -93,5 +99,6 @@ // noop on restState if purging

_persist: _extends({}, _persist, { rehydrated: true })
});
// @NOTE if key does not match, will continue to default else below
});if (action.key === config.key) {
// @NOTE if key does not match, will continue to default else below
if (action.key === config.key) {
var reducedState = baseReducer(restState, action);

@@ -114,6 +121,7 @@ var inboundState = action.payload;

_persist: _persist
// update the persistoid only if we are already rehydrated
});_persist.rehydrated && _persistoid && _persistoid.update(newState);
});
// update the persistoid only if we are already rehydrated and are not paused
_persist.rehydrated && _persistoid && !_paused && _persistoid.update(newState);
return newState;
};
}

@@ -8,3 +8,3 @@ 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; };

import persistReducer from './persistReducer';
import { FLUSH, PERSIST, PURGE, REGISTER, REHYDRATE } from './constants';
import { FLUSH, PAUSE, PERSIST, PURGE, REGISTER, REHYDRATE } from './constants';

@@ -70,2 +70,8 @@ var initialState = {

persistor.pause = function () {
store.dispatch({
type: PAUSE
});
};
var register = function register(key) {

@@ -84,4 +90,5 @@ persistor.dispatch({

key: key
// dispatch to `store` to rehydrate and `persistor` to track result
};store.dispatch(rehydrateAction);
};
// dispatch to `store` to rehydrate and `persistor` to track result
store.dispatch(rehydrateAction);
persistor.dispatch(rehydrateAction);

@@ -94,5 +101,9 @@ if (boostrappedCb && persistor.getState().bootstrapped) {

store.dispatch({ type: PERSIST, register: register, rehydrate: rehydrate });
persistor.persist = function () {
store.dispatch({ type: PERSIST, register: register, rehydrate: rehydrate });
};
persistor.persist();
return persistor;
}

@@ -7,2 +7,3 @@ 'use strict';

var REHYDRATE = exports.REHYDRATE = 'persist/REHYDRATE';
var PAUSE = exports.PAUSE = 'persist/PAUSE';
var PERSIST = exports.PERSIST = 'persist/PERSIST';

@@ -9,0 +10,0 @@ var PURGE = exports.PURGE = 'persist/PURGE';

@@ -51,2 +51,3 @@ 'use strict';

var _purge = false;
var _paused = true;

@@ -68,2 +69,5 @@ if (process.env.NODE_ENV !== 'production') {

if (action.type === _constants.PERSIST) {
// @NOTE PERSIST resumes if paused.
_paused = false;
// @NOTE only ever create persistoid once, ensure we call it at least once, even if _persist has already been set

@@ -106,2 +110,4 @@ if (!_persistoid) _persistoid = (0, _createPersistoid2.default)(config);

});
} else if (action.type === _constants.PAUSE) {
_paused = true;
} else if (action.type === _constants.REHYDRATE) {

@@ -111,5 +117,6 @@ // noop on restState if purging

_persist: _extends({}, _persist, { rehydrated: true })
});
// @NOTE if key does not match, will continue to default else below
});if (action.key === config.key) {
// @NOTE if key does not match, will continue to default else below
if (action.key === config.key) {
var reducedState = baseReducer(restState, action);

@@ -132,6 +139,7 @@ var inboundState = action.payload;

_persist: _persist
// update the persistoid only if we are already rehydrated
});_persist.rehydrated && _persistoid && _persistoid.update(newState);
});
// update the persistoid only if we are already rehydrated and are not paused
_persist.rehydrated && _persistoid && !_paused && _persistoid.update(newState);
return newState;
};
}

@@ -80,2 +80,8 @@ 'use strict';

persistor.pause = function () {
store.dispatch({
type: _constants.PAUSE
});
};
var register = function register(key) {

@@ -94,4 +100,5 @@ persistor.dispatch({

key: key
// dispatch to `store` to rehydrate and `persistor` to track result
};store.dispatch(rehydrateAction);
};
// dispatch to `store` to rehydrate and `persistor` to track result
store.dispatch(rehydrateAction);
persistor.dispatch(rehydrateAction);

@@ -104,5 +111,9 @@ if (boostrappedCb && persistor.getState().bootstrapped) {

store.dispatch({ type: _constants.PERSIST, register: register, rehydrate: rehydrate });
persistor.persist = function () {
store.dispatch({ type: _constants.PERSIST, register: register, rehydrate: rehydrate });
};
persistor.persist();
return persistor;
}
{
"name": "redux-persist",
"version": "5.0.0-rc.5",
"version": "5.0.0-rc.6",
"description": "persist and rehydrate redux stores",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -57,3 +57,20 @@ # Redux Persist

## Breaking Changes
Additionally if you are using react, it is recommended you use the provided [PersistGate](./docs/PersistGate.md) component for integration. This will take care of delaying the rendering of the app until rehydration is complete.
```js
class App extends Component {
//...
render() {
return (
<PersistGate
persistor={persistor}
loading={<Loading />}
>
{/* rest of app */}
</PersistGate>
)
}
}
```
## v5 Breaking Changes
There are two important breaking changes.

@@ -60,0 +77,0 @@ 1. api has changed as described in the above migration section

@@ -6,2 +6,3 @@ // @flow

export const REHYDRATE = 'persist/REHYDRATE'
export const PAUSE = 'persist/PAUSE'
export const PERSIST = 'persist/PERSIST'

@@ -8,0 +9,0 @@ export const PURGE = 'persist/PURGE'

// @flow
import { FLUSH, PERSIST, PURGE, REHYDRATE, DEFAULT_VERSION } from './constants'
import {
FLUSH,
PAUSE,
PERSIST,
PURGE,
REHYDRATE,
DEFAULT_VERSION,
} from './constants'

@@ -42,2 +49,3 @@ import type {

let _purge = false
let _paused = true

@@ -59,2 +67,5 @@ if (process.env.NODE_ENV !== 'production') {

if (action.type === PERSIST) {
// @NOTE PERSIST resumes if paused.
_paused = false
// @NOTE only ever create persistoid once, ensure we call it at least once, even if _persist has already been set

@@ -111,2 +122,4 @@ if (!_persistoid) _persistoid = createPersistoid(config)

}
} else if (action.type === PAUSE) {
_paused = true
} else if (action.type === REHYDRATE) {

@@ -145,6 +158,9 @@ // noop on restState if purging

}
// update the persistoid only if we are already rehydrated
_persist.rehydrated && _persistoid && _persistoid.update(newState)
// update the persistoid only if we are already rehydrated and are not paused
_persist.rehydrated &&
_persistoid &&
!_paused &&
_persistoid.update(newState)
return newState
}
}

@@ -14,3 +14,3 @@ // @flow

import persistReducer from './persistReducer'
import { FLUSH, PERSIST, PURGE, REGISTER, REHYDRATE } from './constants'
import { FLUSH, PAUSE, PERSIST, PURGE, REGISTER, REHYDRATE } from './constants'

@@ -89,2 +89,8 @@ type PendingRehydrate = [Object, RehydrateErrorType, PersistConfig]

persistor.pause = () => {
store.dispatch({
type: PAUSE,
})
}
let register = (key: string) => {

@@ -113,5 +119,9 @@ persistor.dispatch({

store.dispatch({ type: PERSIST, register, rehydrate })
persistor.persist = () => {
store.dispatch({ type: PERSIST, register, rehydrate })
}
persistor.persist()
return persistor
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc