Comparing version
@@ -8,2 +8,12 @@ # Changelog | ||
## [1.1.0] - 2020-10-17 | ||
### Added | ||
- Add `onstorage` event handler to sync state changes between browser tabs | ||
### Changed | ||
- Update documentation to list bundle size | ||
## [1.0.0] - 2020-10-17 | ||
@@ -10,0 +20,0 @@ |
@@ -5,2 +5,3 @@ "use strict"; | ||
var react_1 = require("react"); | ||
var storageEvent_1 = require("./storageEvent"); | ||
var utils_1 = require("./utils"); | ||
@@ -42,2 +43,5 @@ var useStorage = function (storageType, key, initialValue) { | ||
}; | ||
storageEvent_1.registerStorageEventHandler(key, function (newValue) { | ||
setStoredValue(newValue); | ||
}); | ||
return { | ||
@@ -44,0 +48,0 @@ mergeState: mergeState, |
@@ -8,3 +8,3 @@ { | ||
"license": "MIT", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "dist/index.js", | ||
@@ -11,0 +11,0 @@ "types": "dist/index.d.ts", |
@@ -11,4 +11,5 @@ # Haversack | ||
- JSON state merging | ||
- Event handling to sync state between browser tabs | ||
- SSR friendly, Next.js compatible | ||
- Small and performant ⚡️ | ||
- Small and performant (no dependencies, 732B Minified + gzipped) ⚡️ | ||
@@ -165,2 +166,6 @@ `sessionStorage` is an underrepresented feature as most libraries don't support using either API interchangeably. Storing data to the session is more secure, and is perfectly suitable for many use-cases. Learn about the difference [on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API)! | ||
## Storage event sync | ||
Each time you implement a Haversack hook, an `onstorage` event handler is registered. Any instance of your component on alternate browser tabs will be notified that `localStorage` has changed, and update the `value` accordingly. | ||
## Notes on Server-Side Rendering Compatibility | ||
@@ -167,0 +172,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
20815
12.37%20
25%136
17.24%184
2.79%0
-100%