1.1.0 • Published 4 years ago

nedux-persist v1.1.0

Weekly downloads
13
License
ISC
Repository
github
Last release
4 years ago

nedux-persist - persist your nedux store

typescript version size

The official middleware persistor for nedux. Performant and flexible.

📦 Installation

npm install nedux-persist --save

💻 Usage with examples

NameCodesandbox
🔒 Persisting Tokenherehere

📜 Documentation

Import

// ES6
import { persistKeys } from 'nedux-persist';

// ES5
var persistKeys = require('nedux-persist').persistKeys;

persistKeys(keys, [localStorage])

Create a middleware that may your keys persisted.

argumentrequiredtypedescription
keysstring[]The keys that you want to persist
localStorageStorageThe keys that you want to persist

Storage

argumentrequiredtypedescription
getItem(key: string) => stringGet the value from Storage
setItem(key: string, value: string) => voidSet the value into Storage

🎛 Basic Usage

import { createStore } from 'nedux';
import { persistKeys } from 'nedux-persist';

type Store = {
  token: string;
  useless: number;
};

const store = createStore<Store>(
  { token: '', useless: 0 },
  [persistKeys(['token'])],
);

store.subscribe('token', { next: token => console.log(`token: ${token}`) });

🙋🏼 Contributions

All Pull Requests, Issues and Discussions are welcomed !

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago