mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Add transformState function to redux-localstorage
This commit is contained in:
2
types/redux-localstorage/index.d.ts
vendored
2
types/redux-localstorage/index.d.ts
vendored
@@ -26,4 +26,6 @@ export function mergePersistedState(merge?: <A1, A2>(initialState: A1, persisten
|
||||
|
||||
export default function persistState<A>(storage?: StorageAdapter<A>, key?: string, callback?: Function): Redux.GenericStoreEnhancer;
|
||||
|
||||
export function transformState<A1, A2>(down: ((state: A1) => A2) | Array<(state: any) => any>, up: ((state: A2) => A1) | Array<(state: any) => any>): (storage: StorageAdapter<A1>) => A2;
|
||||
|
||||
export const actionTypes: ActionTypes;
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Reducer, compose, combineReducers, createStore } from "redux";
|
||||
import {
|
||||
default as persistState,
|
||||
mergePersistedState,
|
||||
transformState,
|
||||
actionTypes
|
||||
} from "redux-localstorage";
|
||||
import * as adapterAsyncStorage from "redux-localstorage/lib/adapters/AsyncStorage";
|
||||
@@ -31,3 +32,7 @@ const createStoreLocalStorage = compose(
|
||||
const createStoreSessionStorage = compose(
|
||||
persistState(storageSessionStorage, "foo")
|
||||
)(createStore)(reducer);
|
||||
|
||||
const storage = compose(
|
||||
transformState([JSON.stringify, btoa], [atob, JSON.parse])
|
||||
)(storageLocalStorage);
|
||||
|
||||
Reference in New Issue
Block a user