pass in bundle url as a dependency of RCTHost (#37568)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37568 Changelog: [Internal] since bundleURL is constant throughout an app session, we should pass it in as a dependency from above. in the next diff, i'll get rid of `getBundleURL` from the react host's delegate. Reviewed By: sammy-SC Differential Revision: D45937855 fbshipit-source-id: 6306407f25c0f3eb8547e6aaf6e10ed9d2fddeaa
This commit is contained in:
Родитель
c24b5e9d02
Коммит
fb64bbf671
|
@ -48,7 +48,8 @@ typedef std::shared_ptr<facebook::react::JSEngineInstance> (^RCTHostJSEngineProv
|
|||
*/
|
||||
@interface RCTHost : NSObject
|
||||
|
||||
- (instancetype)initWithHostDelegate:(id<RCTHostDelegate>)hostDelegate
|
||||
- (instancetype)initWithBundleURL:(NSURL *)bundleURL
|
||||
hostDelegate:(id<RCTHostDelegate>)hostDelegate
|
||||
turboModuleManagerDelegate:(id<RCTTurboModuleManagerDelegate>)turboModuleManagerDelegate
|
||||
bindingsInstallFunc:(facebook::react::ReactInstance::BindingsInstallFunc)bindingsInstallFunc
|
||||
jsEngineProvider:(RCTHostJSEngineProvider)jsEngineProvider NS_DESIGNATED_INITIALIZER FB_OBJC_DIRECT;
|
||||
|
|
|
@ -52,7 +52,8 @@ using namespace facebook::react;
|
|||
Host initialization should not be resource intensive. A host may be created before any intention of using React Native
|
||||
has been expressed.
|
||||
*/
|
||||
- (instancetype)initWithHostDelegate:(id<RCTHostDelegate>)hostDelegate
|
||||
- (instancetype)initWithBundleURL:(NSURL *)bundleURL
|
||||
hostDelegate:(id<RCTHostDelegate>)hostDelegate
|
||||
turboModuleManagerDelegate:(id<RCTTurboModuleManagerDelegate>)turboModuleManagerDelegate
|
||||
bindingsInstallFunc:(facebook::react::ReactInstance::BindingsInstallFunc)bindingsInstallFunc
|
||||
jsEngineProvider:(RCTHostJSEngineProvider)jsEngineProvider
|
||||
|
@ -78,7 +79,7 @@ using namespace facebook::react;
|
|||
return strongSelf->_bundleURL;
|
||||
};
|
||||
|
||||
auto bundleURLSetter = ^(NSURL *bundleURL) {
|
||||
auto bundleURLSetter = ^(NSURL *bundleURL_) {
|
||||
[weakSelf _setBundleURL:bundleURL];
|
||||
};
|
||||
|
||||
|
@ -92,6 +93,7 @@ using namespace facebook::react;
|
|||
return [strongSelf->_hostDelegate getBundleURL];
|
||||
};
|
||||
|
||||
[self _setBundleURL:bundleURL];
|
||||
[_bundleManager setBridgelessBundleURLGetter:bundleURLGetter
|
||||
andSetter:bundleURLSetter
|
||||
andDefaultGetter:defaultBundleURLGetter];
|
||||
|
@ -140,7 +142,6 @@ using namespace facebook::react;
|
|||
@"RCTHost should not be creating a new instance if one already exists. This implies there is a bug with how/when this method is being called.");
|
||||
[_instance invalidate];
|
||||
}
|
||||
[self _setBundleURL:[_hostDelegate getBundleURL]];
|
||||
_instance = [[RCTInstance alloc] initWithDelegate:self
|
||||
jsEngineInstance:[self _provideJSEngine]
|
||||
bundleManager:_bundleManager
|
||||
|
|
|
@ -20,6 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
RCT_EXTERN_C_BEGIN
|
||||
|
||||
RCTHost *RCTHostCreateDefault(
|
||||
NSURL *bundleURL,
|
||||
id<RCTHostDelegate> hostDelegate,
|
||||
id<RCTTurboModuleManagerDelegate> turboModuleManagerDelegate,
|
||||
RCTHostJSEngineProvider jsEngineProvider);
|
||||
|
|
|
@ -8,11 +8,13 @@
|
|||
#import "RCTHostCreationHelpers.h"
|
||||
|
||||
RCTHost *RCTHostCreateDefault(
|
||||
NSURL *bundleURL,
|
||||
id<RCTHostDelegate> hostDelegate,
|
||||
id<RCTTurboModuleManagerDelegate> turboModuleManagerDelegate,
|
||||
RCTHostJSEngineProvider jsEngineProvider)
|
||||
{
|
||||
return [[RCTHost alloc] initWithHostDelegate:hostDelegate
|
||||
return [[RCTHost alloc] initWithBundleURL:bundleURL
|
||||
hostDelegate:hostDelegate
|
||||
turboModuleManagerDelegate:turboModuleManagerDelegate
|
||||
bindingsInstallFunc:nullptr
|
||||
jsEngineProvider:jsEngineProvider];
|
||||
|
|
Загрузка…
Ссылка в новой задаче