mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
redux-persist-transform-encrypt 2.0 definitions (#25231)
This commit is contained in:
+6
-2
@@ -1,3 +1,7 @@
|
||||
import createAsyncEncryptor from ".";
|
||||
import { Transform } from "redux-persist";
|
||||
|
||||
export default createAsyncEncryptor;
|
||||
export interface AsyncEncryptorConfig {
|
||||
secretKey: string;
|
||||
}
|
||||
|
||||
export default function createAsyncEncryptor<State, Raw>(config: AsyncEncryptorConfig): Transform<State, Raw>;
|
||||
|
||||
+3
-1
@@ -1,12 +1,14 @@
|
||||
// Type definitions for redux-persist-transform-encrypt 1.0
|
||||
// Type definitions for redux-persist-transform-encrypt 2.0
|
||||
// Project: https://github.com/maxdeviant/redux-persist-transform-encrypt
|
||||
// Definitions by: Karol Janyst <https://github.com/LKay>
|
||||
// Gaurav Lahoti <https://github.com/dante-101>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { Transform } from "redux-persist";
|
||||
|
||||
export interface EncryptorConfig {
|
||||
secretKey: string;
|
||||
onError?: (err: Error) => void;
|
||||
}
|
||||
|
||||
export default function createEncryptor<State, Raw>(config: EncryptorConfig): Transform<State, Raw>;
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
import { createStore, Reducer, Store } from "redux";
|
||||
import { createPersistor, Transform } from "redux-persist";
|
||||
import createEncryptor, { EncryptorConfig } from "redux-persist-transform-encrypt";
|
||||
import createAsyncEncryptor from "redux-persist-transform-encrypt/async";
|
||||
import createAsyncEncryptor, { AsyncEncryptorConfig } from "redux-persist-transform-encrypt/async";
|
||||
|
||||
const reducer: Reducer<any> = (state: any, action: any) => ({ state, action });
|
||||
|
||||
const config: EncryptorConfig = { secretKey : "foo" };
|
||||
const config: EncryptorConfig = {
|
||||
secretKey: "foo",
|
||||
onError: (err: Error) => { err.message; }
|
||||
};
|
||||
const encryptor: Transform<any, any> = createEncryptor(config);
|
||||
const asyncEncryptor: Transform<any, any> = createAsyncEncryptor(config);
|
||||
|
||||
const configNoError: EncryptorConfig = { secretKey: "foo" };
|
||||
const encryptorNoError: Transform<any, any> = createEncryptor(configNoError);
|
||||
|
||||
const asyncConfig: AsyncEncryptorConfig = { secretKey: "foo" };
|
||||
const asyncEncryptor: Transform<any, any> = createAsyncEncryptor(asyncConfig);
|
||||
|
||||
const store: Store<any> = createStore(reducer);
|
||||
|
||||
createPersistor(store, { transforms : [encryptor, asyncEncryptor] });
|
||||
createPersistor(store, { transforms : [encryptor, encryptorNoError, asyncEncryptor] });
|
||||
|
||||
Reference in New Issue
Block a user