Skip to content

Commit

Permalink
introduce RCTHostCreationHelpers
Browse files Browse the repository at this point in the history
Summary:
Changelog: [Internal]
in this diff, i introduced a C function to be used to create RCTHost that obfuscates away all the C++ arguments. i expect this to be the API that the vast majority of the community will use to create `RCTHost`.

Differential Revision: D45678970

fbshipit-source-id: d3610b641498e17e628d8e346990dc346145b6b9
  • Loading branch information
philIip authored and facebook-github-bot committed May 9, 2023
1 parent b0c2e2a commit 6154224
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#import <React/RCTDefines.h>
#import <UIKit/UIKit.h>

@class RCTHost;

@protocol RCTHostDelegate;
@protocol RCTTurboModuleManagerDelegate;

RCT_EXTERN_C_BEGIN

RCTHost *RCTHostCreateDefault(
id<RCTHostDelegate> hostDelegate,
id<RCTTurboModuleManagerDelegate> turboModuleManagerDelegate);

RCT_EXTERN_C_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#import "RCTHostCreationHelpers.h"

#import <ReactCommon/RCTHermesInstance.h>
#import <react/bridgeless/ReactInstance.h>

#import "RCTHost.h"

RCTHost *RCTHostCreateDefault(
id<RCTHostDelegate> hostDelegate,
id<RCTTurboModuleManagerDelegate> turboModuleManagerDelegate)
{
return [[RCTHost alloc] initWithHostDelegate:hostDelegate
turboModuleManagerDelegate:turboModuleManagerDelegate
bindingsInstallFunc:nullptr
jsErrorHandlingFunc:nullptr
jsEngineProvider:^std::shared_ptr<facebook::react::JSEngineInstance>() {
return std::make_shared<facebook::react::RCTHermesInstance>();
}];
}

0 comments on commit 6154224

Please sign in to comment.