@cycle/storage
Advanced tools
Comparing version 5.0.3 to 5.1.0
{ | ||
"name": "@cycle/storage", | ||
"version": "5.0.3", | ||
"version": "5.1.0", | ||
"description": "A Cycle.js driver for localStorage and sessionStorage.", | ||
@@ -20,2 +20,6 @@ "author": "Kahlil Lechelt", | ||
"email": "ntilwalli@gmail.com" | ||
}, | ||
{ | ||
"name": "Fabiano Taioli", | ||
"email": "ftaioli@gmail.com" | ||
} | ||
@@ -31,4 +35,4 @@ ], | ||
"devDependencies": { | ||
"@cycle/dom": "^20.1.0", | ||
"@types/node": "^8.0.19", | ||
"@cycle/dom": "^22.8.0", | ||
"@types/node": "^14.14.14", | ||
"@types/tape": "^4.2.30", | ||
@@ -48,3 +52,3 @@ "babel-preset-es2015": "^6.24.1", | ||
"ts-node": "^3.3.0", | ||
"typescript": "^2.4.2", | ||
"typescript": "^4.1.3", | ||
"xstream": "^11.0.0" | ||
@@ -51,0 +55,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
import {Stream} from 'xstream'; | ||
import xs, {Stream} from 'xstream'; | ||
import dropRepeats from 'xstream/extra/dropRepeats'; | ||
@@ -6,2 +6,23 @@ import {adapt} from '@cycle/run/lib/adapt'; | ||
const extStorageProducer = { | ||
start: function (listener) { | ||
this.sendReq = function(storage): void { | ||
listener.next({ | ||
target: 'local', | ||
key: storage.key, | ||
value: storage.newValue | ||
}) | ||
} | ||
window.addEventListener('storage', this.sendReq) | ||
}, | ||
stop: function () { | ||
window.removeEventListener('storage', this.sendReq) | ||
} | ||
} | ||
const extStorage$: Stream<StorageRequest> = typeof window !== "undefined" | ||
? xs.create(extStorageProducer) | ||
: xs.never() | ||
function getStorage$( | ||
@@ -12,3 +33,6 @@ request$: Stream<StorageRequest>, | ||
if (type === 'local') { | ||
return request$.filter(req => !req.target || req.target === 'local'); | ||
return xs.merge( | ||
request$.filter(req => !req.target || req.target === 'local'), | ||
extStorage$ | ||
); | ||
} else { | ||
@@ -15,0 +39,0 @@ return request$.filter(req => req.target === 'session'); |
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
26380
525
23
1