Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Avoid using window.localStorage when loading the persist file
  • Loading branch information
youknowriad committed Jul 24, 2018
commit 2d87fe0b741615651a852d912410f719d9a0427d
20 changes: 10 additions & 10 deletions packages/data/src/persist.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Defaults to the local storage.
let persistenceStorage = window.localStorage;
let persistenceStorage;

/**
* Sets a different persistence storage.
Expand All @@ -10,6 +10,15 @@ export function setPersistenceStorage( storage ) {
persistenceStorage = storage;
}

/**
* Get the persistence storage handler.
*
* @return {Object} Persistence storage.
*/
export function getPersistenceStorage() {
return persistenceStorage || window.localStorage;
}

/**
* Adds the rehydration behavior to redux reducers.
*
Expand Down Expand Up @@ -72,12 +81,3 @@ export function restrictPersistence( reducer, keyToPersist ) {
return nextState;
};
}

/**
* Get the persistence storage handler.
*
* @return {Object} Persistence storage.
*/
export function getPersistenceStorage() {
return persistenceStorage;
}