Socket
Socket
Sign inDemoInstall

kea-localstorage

Package Overview
Dependencies
9
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

9

CHANGELOG.md
# Change Log
All notable changes to this project will be documented in this file.
## 1.0.2 - 2020-04-17
- Added `logic.cache.localStorageDefaults[reducerKey]` to hold on to the original default of the reducer
- Fixed edge case where a reducer with the key `stored` would never be stored in localStorage if defined
in a `logic.extend()` call
## 1.0.1 - 2020-04-13
### Fixed
- Fixed bug where extending a logic with stored values would re-store the values

@@ -10,3 +14,2 @@ - Fixed bug where using in .extend() would require a path to be given again

## 1.0.0 - 2019-09-12
### Changed
- Works with kea 1.0.

@@ -16,7 +19,5 @@ - Use `localStoragePlugin.configure(storageEngine)` to provide an alternative storage engine

## 0.3.0 - 2019-09-07
### Feat
- Add configure (prefix and separator) to plugin
## 0.1.0 - 2017-10-25
### Changed
- First version

@@ -70,2 +70,4 @@ /* global test, expect */

expect(logicWithStorage.cache.localStorageDefaults.number).toBe(12);
expect(wrapper.find('.number').text()).toEqual('12');

@@ -133,2 +135,3 @@

));
expect(logicWithStorage.cache.localStorageDefaults.number).toBe(12);

@@ -135,0 +138,0 @@ expect(wrapper.find('.number').text()).toEqual('42'); // even if value says 12 in the logic store

@@ -55,5 +55,9 @@ import { getPluginContext, setPluginContext } from 'kea';

if (!logic.cache.localStorage) {
logic.cache.localStorage = { stored: {} };
logic.cache.localStorage = {};
}
if (!logic.cache.localStorageDefaults) {
logic.cache.localStorageDefaults = {};
}
if (!input.path && logic.pathString.indexOf('kea.inline.') === 0) {

@@ -74,2 +78,4 @@ console.error('Logic store must have a path specified in order to persist reducer values');

logic.cache.localStorageDefaults[key] = logic.defaults[key];
if (typeof storageEngine[path] !== 'undefined') {

@@ -76,0 +82,0 @@ logic.defaults[key] = JSON.parse(storageEngine[path]);

@@ -90,2 +90,4 @@ 'use strict';

expect(logicWithStorage.cache.localStorageDefaults.number).toBe(12);
expect(wrapper.find('.number').text()).toEqual('12');

@@ -153,2 +155,3 @@

));
expect(logicWithStorage.cache.localStorageDefaults.number).toBe(12);

@@ -155,0 +158,0 @@ expect(wrapper.find('.number').text()).toEqual('42'); // even if value says 12 in the logic store

@@ -59,5 +59,9 @@ 'use strict';

if (!logic.cache.localStorage) {
logic.cache.localStorage = { stored: {} };
logic.cache.localStorage = {};
}
if (!logic.cache.localStorageDefaults) {
logic.cache.localStorageDefaults = {};
}
if (!input.path && logic.pathString.indexOf('kea.inline.') === 0) {

@@ -78,2 +82,4 @@ console.error('Logic store must have a path specified in order to persist reducer values');

logic.cache.localStorageDefaults[key] = logic.defaults[key];
if (typeof storageEngine[path] !== 'undefined') {

@@ -80,0 +86,0 @@ logic.defaults[key] = JSON.parse(storageEngine[path]);

{
"name": "kea-localstorage",
"version": "1.0.1",
"version": "1.0.2",
"description": "Store reducer state in localStorage with Kea",

@@ -5,0 +5,0 @@ "author": "Marius Andra",

@@ -92,1 +92,10 @@ ![NPM Version](https://img.shields.io/npm/v/kea-thunk.svg)

Now the `persistedValue` will not be saved in `scenes.something.foobar`, but in `example_scenes_something_foobar`
### Get the original default of the reducer
Under the hood `kea-localstorage` overrides the `defaults` value for your reducer with whatever was
stored in localstorage. In case you need to access the original default, it's stored here:
```javascript
logic.cache.localStorageDefaults['reducerKey']
```

@@ -50,2 +50,4 @@ /* global test, expect */

expect(logicWithStorage.cache.localStorageDefaults.number).toBe(12)
expect(wrapper.find('.number').text()).toEqual('12')

@@ -93,2 +95,3 @@

)
expect(logicWithStorage.cache.localStorageDefaults.number).toBe(12)

@@ -95,0 +98,0 @@ expect(wrapper.find('.number').text()).toEqual('42') // even if value says 12 in the logic store

@@ -47,5 +47,9 @@ import { getPluginContext, setPluginContext } from 'kea'

if (!logic.cache.localStorage) {
logic.cache.localStorage = { stored: {} }
logic.cache.localStorage = {}
}
if (!logic.cache.localStorageDefaults) {
logic.cache.localStorageDefaults = {}
}
if (!input.path && logic.pathString.indexOf('kea.inline.') === 0) {

@@ -65,2 +69,4 @@ console.error('Logic store must have a path specified in order to persist reducer values')

logic.cache.localStorageDefaults[key] = logic.defaults[key]
if (typeof storageEngine[path] !== 'undefined') {

@@ -67,0 +73,0 @@ logic.defaults[key] = JSON.parse(storageEngine[path])

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