mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
use self instead of class name when doing strong / weak dance (#37442)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37442 Changelog: [Internal] this better describes what's going on and is more standard obj-c Reviewed By: javache Differential Revision: D45805034 fbshipit-source-id: d8e5938c856f356ce96a3f6d393eaddbb02aa555
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5f9a11c7d1
commit
a6c658ff69
@@ -69,34 +69,34 @@ NSString *const RCTHostDidReloadNotification = @"RCTHostDidReloadNotification";
|
||||
_moduleRegistry = [RCTModuleRegistry new];
|
||||
_jsEngineProvider = [jsEngineProvider copy];
|
||||
|
||||
__weak RCTHost *weakHost = self;
|
||||
__weak RCTHost *weakSelf = self;
|
||||
|
||||
auto bundleURLGetter = ^NSURL *()
|
||||
{
|
||||
RCTHost *strongHost = weakHost;
|
||||
if (!strongHost) {
|
||||
RCTHost *strongSelf = weakSelf;
|
||||
if (!strongSelf) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return strongHost->_bundleURL;
|
||||
return strongSelf->_bundleURL;
|
||||
};
|
||||
|
||||
auto bundleURLSetter = ^(NSURL *bundleURL) {
|
||||
RCTHost *strongHost = weakHost;
|
||||
if (!strongHost) {
|
||||
RCTHost *strongSelf = weakSelf;
|
||||
if (!strongSelf) {
|
||||
return;
|
||||
}
|
||||
strongHost->_bundleURL = bundleURL;
|
||||
strongSelf->_bundleURL = bundleURL;
|
||||
};
|
||||
|
||||
auto defaultBundleURLGetter = ^NSURL *()
|
||||
{
|
||||
RCTHost *strongHost = weakHost;
|
||||
if (!strongHost) {
|
||||
RCTHost *strongSelf = weakSelf;
|
||||
if (!strongSelf) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [strongHost->_hostDelegate getBundleURL];
|
||||
return [strongSelf->_hostDelegate getBundleURL];
|
||||
};
|
||||
|
||||
[_bundleManager setBridgelessBundleURLGetter:bundleURLGetter
|
||||
@@ -112,17 +112,17 @@ NSString *const RCTHostDidReloadNotification = @"RCTHostDidReloadNotification";
|
||||
* JS calls before the main JSBundle finishes execution, and execute them after.
|
||||
*/
|
||||
_onInitialBundleLoad = ^{
|
||||
RCTHost *strongHost = weakHost;
|
||||
if (!strongHost) {
|
||||
RCTHost *strongSelf = weakSelf;
|
||||
if (!strongSelf) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSArray<RCTFabricSurface *> *unstartedSurfaces = @[];
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> guard{strongHost->_surfaceStartBufferMutex};
|
||||
unstartedSurfaces = [NSArray arrayWithArray:strongHost->_surfaceStartBuffer];
|
||||
strongHost->_surfaceStartBuffer = nil;
|
||||
std::lock_guard<std::mutex> guard{strongSelf->_surfaceStartBufferMutex};
|
||||
unstartedSurfaces = [NSArray arrayWithArray:strongSelf->_surfaceStartBuffer];
|
||||
strongSelf->_surfaceStartBuffer = nil;
|
||||
}
|
||||
|
||||
for (RCTFabricSurface *surface in unstartedSurfaces) {
|
||||
|
||||
@@ -107,12 +107,12 @@ void RCTInstanceSetRuntimeDiagnosticFlags(NSString *flags)
|
||||
bundleManager:bundleManager
|
||||
callableJSModules:[RCTCallableJSModules new]];
|
||||
{
|
||||
__weak __typeof(self) weakInstance = self;
|
||||
__weak __typeof(self) weakSelf = self;
|
||||
[_bridgeModuleDecorator.callableJSModules
|
||||
setBridgelessJSModuleMethodInvoker:^(
|
||||
NSString *moduleName, NSString *methodName, NSArray *args, dispatch_block_t onComplete) {
|
||||
// TODO: Make RCTInstance call onComplete
|
||||
[weakInstance callFunctionOnJSModule:moduleName method:methodName args:args];
|
||||
[weakSelf callFunctionOnJSModule:moduleName method:methodName args:args];
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -304,10 +304,10 @@ void RCTInstanceSetRuntimeDiagnosticFlags(NSString *flags)
|
||||
|
||||
- (void)_attachBridgelessAPIsToModule:(id<RCTTurboModule>)module FB_OBJC_DIRECT
|
||||
{
|
||||
__weak RCTInstance *weakInstance = self;
|
||||
__weak RCTInstance *weakSelf = self;
|
||||
if ([module respondsToSelector:@selector(setDispatchToJSThread:)]) {
|
||||
((id<RCTJSDispatcherModule>)module).dispatchToJSThread = ^(dispatch_block_t block) {
|
||||
__strong __typeof(self) strongSelf = weakInstance;
|
||||
__strong __typeof(self) strongSelf = weakSelf;
|
||||
|
||||
if (strongSelf && strongSelf->_valid) {
|
||||
strongSelf->_reactInstance->getBufferedRuntimeExecutor()([=](jsi::Runtime &runtime) { block(); });
|
||||
|
||||
Reference in New Issue
Block a user