@zhourengui/redux-async-persist
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

Redux Async Persist

Support asynchronous persistent redux

Installation

npm install @zhourengui/redux-async-persist
# or
yarn add @zhourengui/redux-async-persist

Usage

An example used in vue

import { useReduxPersist } from './persist_store';
import { store } from './stores';
import { getCurrentInstance } from '@vue/runtime-core';
import { onBeforeUnmount } from '@vue/runtime-core';

useReduxPersist({
  key: 'chrome_extension',
  store: store, // redux store
  persistKeys: ['term'], // persist keys
  storage: {
    getItem: async (key: string) =>
      (await chrome.storage.local.get([key]))[key],
    setItem: async (key: string, value: any) =>
      await chrome.storage.local.set({ [key]: value }),
  },
  baseReducer: baseReducer // redux reducers,
  disposed: (unsubscribe) => onBeforeUnmount(unsubscribe, app), // unsubscribe
});

Package Sidebar

Install

npm i @zhourengui/redux-async-persist

Weekly Downloads

5

Version

0.1.4

License

MIT

Unpacked Size

10.1 kB

Total Files

5

Last publish

Collaborators

  • zhourengui