-
Notifications
You must be signed in to change notification settings - Fork 31
feat(ios): add bundleURL provider for dynamic bundle loading #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
artus9033
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution @gronxb ! This looks awesome, left just one comment to rename the new option, other than that LGTM.
One more question, do you have feature parity in the current state on Android? I'm wondering if we need an equivalent feature in Android, where I think we currently would need to destroy & reinitialize the whole ReactHost, right?
| | `fallbackResource` | `String?` | `nil` | Path to bundle fallback resource. | | ||
| | `bundlePath` | `String` | `main.jsbundle` | Path to bundle fallback resource. | | ||
| | `bundle` | `Bundle` | `Bundle.main` | Bundle instance to lookup the JavaScript bundle resource. | | ||
| | `bundleURL` | `(() -> URL?)?` | `nil` | Dynamic bundle URL provider called on every bundle load. When set, overrides default behavior. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[minor] I would suggest we name it bundleURLOverride, this way we will be explicit about which field takes precedence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done !
|
For Android, from my perspective there’s no additional feature needed anymore. For reload behavior, we rely on the React Native API itself. On iOS, I use: On Android, we use: In the iOS case, Unfortunately, So once this gets merged, I don’t see any remaining issues from my side! Therefore, since this is already how things work in greenfield setups, there isn’t really anything additional we need to do for brownfield Android. |
Summary
This is a follow-up to Android OTA support. Also, to support iOS reliably, we needed additional functionality.
In a typical OTA flow, when a force update occurs, we need to reload the current JSContext. In this case, ReactNativeDelegate’s bundleURL() is re-evaluated/reset without terminating the app, so even after the reload, we must be able to correctly reflect the latest bundle URL. Therefore, we need to be able to control this flow via a callback/hook.
However, with the currently provided options (bundlePath, bundle) alone:
In conclusion, the existing options don’t provide sufficient control, so we added a field that allows fully overriding the bundleURL() logic itself.
This field could be exposed under a name like overrideBundleURL(), for example.
Test plan
ios2.mov