Skip to content

Commit ba302ca

Browse files
committed
iOS implementation
1 parent 056b61e commit ba302ca

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

ios/RNCAsyncStorage.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#import <React/RCTBridgeModule.h>
1111
#import <React/RCTInvalidating.h>
1212

13+
#ifdef RCT_NEW_ARCH_ENABLED
14+
#import <rnasyncstorage/rnasyncstorage.h>
15+
#endif
16+
1317
#import "RNCAsyncStorageDelegate.h"
1418

1519
/**
@@ -23,7 +27,13 @@
2327
*
2428
* Keys and values must always be strings or an error is returned.
2529
*/
26-
@interface RNCAsyncStorage : NSObject <RCTBridgeModule, RCTInvalidating>
30+
@interface RNCAsyncStorage : NSObject <
31+
#ifdef RCT_NEW_ARCH_ENABLED
32+
NativeAsyncStorageModuleSpec
33+
#else
34+
RCTBridgeModule
35+
#endif
36+
, RCTInvalidating>
2737

2838
@property (nonatomic, weak, nullable) id<RNCAsyncStorageDelegate> delegate;
2939

ios/RNCAsyncStorage.m renamed to ios/RNCAsyncStorage.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,4 +895,12 @@ - (BOOL)_passthroughDelegate
895895
}
896896
}
897897

898+
#if RCT_NEW_ARCH_ENABLED
899+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
900+
(const facebook::react::ObjCTurboModule::InitParams &)params
901+
{
902+
return std::make_shared<facebook::react::NativeAsyncStorageModuleSpecJSI>(params);
903+
}
904+
#endif
905+
898906
@end

src/RCTAsyncStorage.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
import { NativeModules, TurboModuleRegistry } from 'react-native';
33
import { shouldFallbackToLegacyNativeModule } from './shouldFallbackToLegacyNativeModule';
44

5+
import AsyncStorageTurboModule from './NativeAsyncStorageModule';
6+
57
let RCTAsyncStorage =
8+
AsyncStorageTurboModule ||
69
NativeModules['PlatformLocalStorage'] || // Support for external modules, like react-native-windows
710
NativeModules['RNC_AsyncSQLiteDBStorage'] ||
811
NativeModules['RNCAsyncStorage'];

0 commit comments

Comments
 (0)