From 90cd5050a5c40097826c0e0d87e31f457fdbdd53 Mon Sep 17 00:00:00 2001 From: Jan Kalfus Date: Fri, 5 Aug 2016 20:04:59 +0200 Subject: [PATCH 1/2] Added definition for redux-storage-engine-reactnativeasyncstorage (it has the same interface as redux-storage-localstorage). --- redux-storage/redux-storage.d.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/redux-storage/redux-storage.d.ts b/redux-storage/redux-storage.d.ts index 8debaf59d4..e9583d157b 100644 --- a/redux-storage/redux-storage.d.ts +++ b/redux-storage/redux-storage.d.ts @@ -96,6 +96,18 @@ declare module "redux-storage-engine-localstorage" { export default function createEngine(key: string): LocalStorageEngine; } +declare module "redux-storage-engine-reactnativeasyncstorage" { + import { StorageEngine } from "redux-storage"; + + export interface ReactNativeAsyncStorageEngine extends StorageEngine {} + + /** + * Create React Native Async Storage + * @param key React Native Async Storage key + */ + export default function createEngine(key: string): ReactNativeAsyncStorageEngine; +} + declare module "redux-storage-merger-immutablejs" { import { StateMerger } from "redux-storage"; From 22798b0a56382445571c1caa7a30029a4847afc7 Mon Sep 17 00:00:00 2001 From: Jan Kalfus Date: Fri, 5 Aug 2016 20:18:02 +0200 Subject: [PATCH 2/2] Added test for "redux-storage-engine-reactnativeasyncstorage" --- redux-storage/redux-storage-tests.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/redux-storage/redux-storage-tests.ts b/redux-storage/redux-storage-tests.ts index bb38066d0a..484366c925 100644 --- a/redux-storage/redux-storage-tests.ts +++ b/redux-storage/redux-storage-tests.ts @@ -6,6 +6,7 @@ import { reducer, createMiddleware, createLoader } from "redux-storage"; import reduxStorageImmutableMerger from "redux-storage-merger-immutablejs"; import filter from "redux-storage-decorator-filter"; import createEngine from "redux-storage-engine-localstorage"; +import createReactNativeAsyncStorageEngine from "redux-storage-engine-reactnativeasyncstorage"; interface TestState { a: number; @@ -29,3 +30,12 @@ const store = applyMiddleware(storageMiddleware)(createStore)(enhancedReducer); initialStateLoader(store).then(() => { // render app }) + + +// Test for React Native Async Storage engine +const storageEngineReactNative = createReactNativeAsyncStorageEngine("test"); +const storageMiddlewareReactNative = createMiddleware(storageEngine); +const storeReactNative = applyMiddleware(storageMiddlewareReactNative)(createStore)(enhancedReducer); +initialStateLoader(storeReactNative).then(() => { + // render app +})