-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Description
Now we have two options for loading Javascript code,
1)Load from a development server,
1.a) use localhost:8081 for running on simulator
1.b) on iOS device, use an IP address and need to make sure the device and development computer has same network sub mask.
2) Load from a static bundled file.
option 1 can't work without WiFi, option 2 cannot support live reload, bad influence to development velocity.
Here is a simpler way to deploy Javascript code, so that we don't need to change objc source code when moving to different network, and even runs without network.
- Get updateURL from device storage, use "localhost:8081/default.bundle" by default.
load and run bundle from updateURL.
compare newly downloaded bundle with the stock bundle, reload bundle if newer. - If the new bundle is running properly, write the new bundle to device storage.
- If the newly download bundle is not ok, the app will back to normal restart and and go offline, or turn off the development web server, as app will use stock bundle instead.
- The app might invoke setUpdateURL to set a new update url (whenever the app URL differ from updateURL), thus trigger a reload of bundle. we can switch to different bundle easily without touching the obj c code if the app rely on same set of native feature.
This will reduce the need of frequent change of obj c code, and we can develop app without running xcode,or even write app on windows and linux (watcher and react-native packager should be cross platform).