Commit 4626732
Deprecate RCTHostRuntimeDelegate and merge into RCTHostDelegate (react#54915)
Summary:
Currently, there are two delegate protocols related to the `RCTHost` class that Frameworks can use: `RCTHostDelegate` and `RCTHostRuntimeDelegate`.
`RCTHostDelegate` is easy to set and use as `RCTReactNativeFactory` already conforms to it. However, using the `RCTHostRuntimeDelegate` is less convenient because it can only be set via the host's `runtimeDelegate` property. This requires access to the host instance first, which in turn means having to wait for `hostDidStart` (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 `hostDidStart` is called before `host:didInitializeRuntime`, especially since both are called from different threads. Relying on this ordering feels unsafe to me.
I'm proposing to merge `RCTHostRuntimeDelegate` into `RCTHostDelegate` as they effectively serve the same purpose.
As part of this change, I've deprecated `RCTHostRuntimeDelegate` and 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) to `RCTHostDelegate`.
All call sites and tests have been updated accordingly.
## Changelog:
[IOS] [DEPRECATED] - Deprecate `RCTHostRuntimeDelegate` and merge into `RCTHostDelegate`
Pull Request resolved: react#54915
Test Plan:
- Manually added `host:didInitializeRuntime:` to `RCTReactNativeFactory` and confirmed it gets called
- Tested this change in Expo and our own factory
- Native unit tests are passing (for both the deprecated and new method)
Reviewed By: cortinico
Differential Revision: D94076719
Pulled By: cipolleschi
fbshipit-source-id: 946d701727eb46653ce083b66875f9b57baf57431 parent 8915d81 commit 4626732
3 files changed
Lines changed: 35 additions & 3 deletions
File tree
- packages/react-native/ReactCommon/react/runtime
- iostests
- platform/ios/ReactCommon
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
165 | 176 | | |
166 | 177 | | |
167 | 178 | | |
| |||
Lines changed: 17 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
52 | 61 | | |
53 | 62 | | |
54 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
55 | 66 | | |
56 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
57 | 70 | | |
58 | 71 | | |
59 | 72 | | |
| |||
84 | 97 | | |
85 | 98 | | |
86 | 99 | | |
87 | | - | |
| 100 | + | |
| 101 | + | |
88 | 102 | | |
89 | 103 | | |
90 | 104 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
374 | 380 | | |
| 381 | + | |
375 | 382 | | |
376 | 383 | | |
377 | 384 | | |
| |||
0 commit comments