Deprecate RCTHostRuntimeDelegate and merge into RCTHostDelegate #54915
+28
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Currently, there are two delegate protocols related to the
RCTHostclass that Frameworks can use:RCTHostDelegateandRCTHostRuntimeDelegate.RCTHostDelegateis easy to set and use asRCTReactNativeFactoryalready conforms to it. However, using theRCTHostRuntimeDelegateis less convenient because it can only be set via the host'sruntimeDelegateproperty. This requires access to the host instance first, which in turn means having to wait forhostDidStart(see how we currently do this in Expo: https://github.com/expo/expo/blob/cacd14059830c00971d90d39cf8aa9e67f5e6de1/packages/expo/ios/AppDelegates/ExpoReactNativeFactory.mm#L28-L36).Additionally it's not clear that
hostDidStartis called beforehost:didInitializeRuntime, especially since both are called from different threads. Relying on this ordering feels unsafe to me.I'm proposing to merge
RCTHostRuntimeDelegateintoRCTHostDelegateas they effectively serve the same purpose.As part of this change, I've deprecated
RCTHostRuntimeDelegateand its method. It can be removed in 0.85 or 0.86, depending on which release allows breaking changes. Instead, I've added the same method (optional) toRCTHostDelegate.All call sites and tests have been updated accordingly.
Changelog:
[IOS] [DEPRECATED] - Deprecate
RCTHostRuntimeDelegateand merge intoRCTHostDelegateTest Plan:
host:didInitializeRuntime:toRCTReactNativeFactoryand confirmed it gets called