browser-redux-sync
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -10,3 +10,3 @@ 'use strict'; | ||
if (chrome.storage) { | ||
if (chrome && chrome.storage) { | ||
exports.configureSync = configureSync = require('./configure'); | ||
@@ -16,3 +16,3 @@ exports.sync = sync = require('./sync'); | ||
} else { | ||
exports.configureSync = configureSync = {}; | ||
exports.configureSync = configureSync = function () {}; | ||
exports.sync = sync = require('redux-persist-crosstab'); | ||
@@ -19,0 +19,0 @@ exports.storage = storage = localStorage; |
@@ -16,3 +16,3 @@ 'use strict'; | ||
var key = Object.keys(e)[0]; | ||
if (key.indexOf(keyPrefix) === 0 && (!chrome.storage.local._lastData || !matches(e[key].newValue)(chrome.storage.local._lastData))) { | ||
if (key && key.indexOf(keyPrefix) === 0 && (!chrome.storage.local._lastData || !matches(e[key].newValue)(chrome.storage.local._lastData))) { | ||
var keyspace = key.substr(keyPrefix.length); | ||
@@ -19,0 +19,0 @@ if (whitelist && whitelist.indexOf(keyspace) === -1) { |
{ | ||
"name": "browser-redux-sync", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Keep redux states in sync for browser extensions and apps.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -1,4 +0,5 @@ | ||
# Cross-browser extensions and Chrome apps states syncing | ||
## Cross-browser extensions and Chrome apps states syncing | ||
Add syncing to your [redux](https://github.com/gaearon/redux) browser (Chrome and [Firefox](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities#storage)) extension or app. | ||
It listens to the `chrome.storage` for [redux-persist](https://github.com/rt2zz/redux-persist) events. When an event occurs it will dispatch a rehydrate action. | ||
If `chrome.storage` is not defined (for Safari and old versions of Firefox), it includes [redux-persist-crosstab](https://github.com/rt2zz/redux-persist-crosstab) to use `localStorage`. | ||
@@ -5,0 +6,0 @@ |
let configureSync, sync, storage; | ||
if (chrome.storage) { | ||
if (chrome && chrome.storage) { | ||
configureSync = require('./configure'); | ||
@@ -9,3 +9,3 @@ sync = require('./sync'); | ||
else { | ||
configureSync = {}; | ||
configureSync = () => {}; | ||
sync = require('redux-persist-crosstab'); | ||
@@ -12,0 +12,0 @@ storage = localStorage; |
@@ -14,3 +14,3 @@ var constants = require('redux-persist/constants'); | ||
var key = Object.keys(e)[0]; | ||
if(key.indexOf(keyPrefix) === 0 && (!chrome.storage.local._lastData || !matches(e[key].newValue)(chrome.storage.local._lastData))){ | ||
if(key && key.indexOf(keyPrefix) === 0 && (!chrome.storage.local._lastData || !matches(e[key].newValue)(chrome.storage.local._lastData))){ | ||
var keyspace = key.substr(keyPrefix.length); | ||
@@ -17,0 +17,0 @@ if(whitelist && whitelist.indexOf(keyspace) === -1){ return } |
Sorry, the diff of this file is not supported yet
43054
28