Skip to content

Commit

Permalink
Make RCTAsyncLocalStorage TurboModule-compatible
Browse files Browse the repository at this point in the history
Summary:
**Note:** This was landed in D17724498 but reverted in D17855088. The revert had nothing to do with this NativeModule.

Changelog: [iOS][Added] Make RCTAsyncLocalStorage TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D17917841

fbshipit-source-id: 0f9dd5f592180d6512ca560007daa531a4da5b59
  • Loading branch information
RSNara authored and facebook-github-bot committed Oct 15, 2019
1 parent da6274b commit 2b62bd7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
3 changes: 3 additions & 0 deletions React/CoreModules/BUCK
Expand Up @@ -72,6 +72,9 @@ rn_apple_library(
) + react_module_plugin_providers(
name = "AlertManager",
native_class_func = "RCTAlertManagerCls",
) + react_module_plugin_providers(
name = "AsyncLocalStorage",
native_class_func = "RCTAsyncLocalStorageCls",
),
plugins_header = "FBCoreModulesPlugins.h",
preprocessor_flags = OBJC_ARC_PREPROCESSOR_FLAGS + get_debug_preprocessor_flags() + rn_extra_build_flags() + [
Expand Down
1 change: 1 addition & 0 deletions React/CoreModules/CoreModulesPlugins.h
Expand Up @@ -40,6 +40,7 @@ Class RCTI18nManagerCls(void) __attribute__((used));
Class RCTSourceCodeCls(void) __attribute__((used));
Class RCTActionSheetManagerCls(void) __attribute__((used));
Class RCTAlertManagerCls(void) __attribute__((used));
Class RCTAsyncLocalStorageCls(void) __attribute__((used));

#ifdef __cplusplus
}
Expand Down
1 change: 1 addition & 0 deletions React/CoreModules/CoreModulesPlugins.mm
Expand Up @@ -29,6 +29,7 @@ Class RCTCoreModulesClassProvider(const char *name) {
{"SourceCode", RCTSourceCodeCls},
{"ActionSheetManager", RCTActionSheetManagerCls},
{"AlertManager", RCTAlertManagerCls},
{"AsyncLocalStorage", RCTAsyncLocalStorageCls},
};

auto p = sCoreModuleClassMap.find(name);
Expand Down
File renamed without changes.
Expand Up @@ -9,12 +9,15 @@

#import <Foundation/Foundation.h>

#import <FBReactNativeSpec/FBReactNativeSpec.h>
#import <CommonCrypto/CommonCryptor.h>
#import <CommonCrypto/CommonDigest.h>

#import "RCTConvert.h"
#import "RCTLog.h"
#import "RCTUtils.h"
#import <React/RCTConvert.h>
#import <React/RCTLog.h>
#import <React/RCTUtils.h>

#import "CoreModulesPlugins.h"

static NSString *const RCTStorageDirectory = @"RCTAsyncLocalStorage_V1";
static NSString *const RCTManifestFileName = @"manifest.json";
Expand Down Expand Up @@ -158,6 +161,9 @@ static dispatch_queue_t RCTGetMethodQueue()

#pragma mark - RCTAsyncLocalStorage

@interface RCTAsyncLocalStorage() <NativeAsyncStorageSpec>
@end

@implementation RCTAsyncLocalStorage
{
BOOL _haveSetup;
Expand Down Expand Up @@ -455,4 +461,13 @@ - (NSDictionary *)_writeEntry:(NSArray<NSString *> *)entry changedManifest:(BOOL
}
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModuleWithJsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
{
return std::make_shared<facebook::react::NativeAsyncStorageSpecJSI>(self, jsInvoker);
}

@end

Class RCTAsyncLocalStorageCls(void) {
return RCTAsyncLocalStorage.class;
}

0 comments on commit 2b62bd7

Please sign in to comment.