mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add and use reloadWithReason to iOS
Summary: This diff adds a new reloading method reloadWithReason that allows callers to provide a reason for why a reload was requested. This reason is useful for understanding why users are reloading, and why Fast Refresh is bailing out to a full reload. I also updated the places we reload with the reasons listed below. **Standard native reasons:** - Redbox - Command - Global hotkey - Profiling controls - Dev menu - reload - Dev menu - reset to default - Dev menu - apply changes **From JavaScript (added in a later diff):** - Fast Refresh - Unrecoverable - Fast Refresh - No root boundary - Fast Refresh - Invalidated boundary - Fast Refresh - Invalidated root boundary **Misc reasons and fallback for when a reason is unavailable:** - Unknown from JS - Uncategorized from JS - Unknown from bridge - Unknown from cxx bridge - Requested from bridge - Custom executor class reset Reviewed By: cpojer Differential Revision: D17499339 fbshipit-source-id: 12a21ffa05708c9b921d93911f190cdffc5c78d5
This commit is contained in:
committed by
Facebook Github Bot
parent
59b96fe9a3
commit
2ccc8fbc28
@@ -254,12 +254,17 @@ RCT_EXTERN void RCTEnableTurboModule(BOOL enabled);
|
||||
/**
|
||||
* Reload the bundle and reset executor & modules. Safe to call from any thread.
|
||||
*/
|
||||
- (void)reload;
|
||||
- (void)reload __deprecated_msg("Call reloadWithReason instead");
|
||||
|
||||
/**
|
||||
* Reload the bundle and reset executor & modules. Safe to call from any thread.
|
||||
*/
|
||||
- (void)reloadWithReason:(NSString *)reason;
|
||||
|
||||
/**
|
||||
* Inform the bridge, and anything subscribing to it, that it should reload.
|
||||
*/
|
||||
- (void)requestReload __deprecated_msg("Call reload instead");
|
||||
- (void)requestReload __deprecated_msg("Call reloadWithReason instead");
|
||||
|
||||
/**
|
||||
* Says whether bridge has started receiving calls from javascript.
|
||||
|
||||
+11
-3
@@ -244,7 +244,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
|
||||
- (void)didReceiveReloadCommand
|
||||
{
|
||||
[self reload];
|
||||
[self reloadWithReason:@"Command"];
|
||||
}
|
||||
|
||||
- (NSArray<Class> *)moduleClasses
|
||||
@@ -290,14 +290,22 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
return [self.batchedBridge moduleIsInitialized:moduleClass];
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy reload, please use reloadWithReason and provide a reason for stats.
|
||||
*/
|
||||
- (void)reload
|
||||
{
|
||||
[self reloadWithReason:@"Unknown from bridge"];
|
||||
}
|
||||
|
||||
- (void)reloadWithReason:(NSString *)reason
|
||||
{
|
||||
#if RCT_ENABLE_INSPECTOR && !TARGET_OS_UIKITFORMAC
|
||||
// Disable debugger to resume the JsVM & avoid thread locks while reloading
|
||||
[RCTInspectorDevServerHelper disableDebugger];
|
||||
#endif
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTBridgeWillReloadNotification object:self];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTBridgeWillReloadNotification object:self userInfo:@{@"reason": reason} ];
|
||||
|
||||
/**
|
||||
* Any thread
|
||||
@@ -314,7 +322,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
|
||||
- (void)requestReload
|
||||
{
|
||||
[self reload];
|
||||
[self reloadWithReason:@"Requested from bridge"];
|
||||
}
|
||||
|
||||
- (Class)bridgeClass
|
||||
|
||||
Reference in New Issue
Block a user