Skip to content

Commit

Permalink
fix: add listener through notification center
Browse files Browse the repository at this point in the history
  • Loading branch information
okwasniewski committed Mar 7, 2024
1 parent 59d2d6c commit 1be613b
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void RCTInstanceSetRuntimeDiagnosticFlags(NSString *flags)
sRuntimeDiagnosticFlags = [flags copy];
}

@interface RCTInstance () <RCTTurboModuleManagerDelegate, RCTTurboModuleManagerRuntimeHandler, RCTReloadListener>
@interface RCTInstance () <RCTTurboModuleManagerDelegate, RCTTurboModuleManagerRuntimeHandler>
@end

@implementation RCTInstance {
Expand Down Expand Up @@ -123,11 +123,18 @@ - (instancetype)initWithDelegate:(id<RCTInstanceDelegate>)delegate
[weakSelf callFunctionOnJSModule:moduleName method:methodName args:args];
}];
}

NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_notifyEventDispatcherObserversOfEvent_DEPRECATED:)
name:@"RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED"
object:nil];
[defaultCenter addObserver:self
selector:@selector(_notifyEventDispatcherObserversOfEvent_DEPRECATED:)
name:@"RCTNotifyEventDispatcherObserversOfEvent_DEPRECATED"
object:nil];

[defaultCenter addObserver:self
selector:@selector(didReceiveReloadCommand)
name:RCTTriggerReloadCommandNotification
object:nil];

[self _start];
}
Expand Down Expand Up @@ -341,10 +348,6 @@ - (void)_start
if (RCTGetUseNativeViewConfigsInBridgelessMode()) {
installLegacyUIManagerConstantsProviderBinding(runtime);
}

RCTExecuteOnMainQueue(^{
RCTRegisterReloadCommandListener(self);
});

[strongSelf->_delegate instance:strongSelf didInitializeRuntime:runtime];

Expand Down Expand Up @@ -472,6 +475,7 @@ - (void)_loadScriptFromSource:(RCTSource *)source
const auto *url = deriveSourceURL(source.url).UTF8String;
_reactInstance->loadScript(std::move(script), url);
[[NSNotificationCenter defaultCenter] postNotificationName:@"RCTInstanceDidLoadBundle" object:nil];


if (_onInitialBundleLoad) {
_onInitialBundleLoad();
Expand Down

0 comments on commit 1be613b

Please sign in to comment.