40. GloriïŹed cURL
String newBobAppPath = cURLToDisk(âhttps://expo.io/@bob/appâ);
String bobAppPath = âfile:///bob-app.jsâ;
if (newBobAppPath != null){
loadApp(newBobAppPath);
} else {
loadApp(bobAppPath);
}
JS Bundle
We donât want to load the JS bundle unnecessarily.
We only want to load the JS bundle if thereâs a new change available.
41. Letâs take a step back
And think about how the web
works for a sec
43. Taking a page out of the web book
{bundleUrl: âbundle.jsâ}
Big JS bundle
bundle.js
index.json
44. Taking a page out of the web book
{bundleUrl: âios-1a2b3c.jsâ}
Big JS bundle
ios-1a2b3c.js
index.json
Bundle name is based oïŹ its md5 hash
45. Taking a page out of the web book
{bundleUrl: âios-7a8b9câ}
Big JS bundle
ios-7a8b9c.js
index.json
Cache the bundleUrl
Only download bundleUrl
if we donât have it cached
46. How do I use an OTA service in my app?
^ these are my app ïŹles
^ this is what my app looks like
47. How do I use an OTA service in my app?
dev tools GUI
^ push this button to upload app to expo server
48. How do I use an OTA service in my app?
Or use the cli if you prefer
> expo publish
Run this command in your project directory to upload to expo servers
49. How often is the server polled for updates?
The default behavior is to poll the server when the app starts up
50. What if I donât like the default behavior?
You can use the Updates module to customize when youâd to update your app
^ from the docs page
52. Iâm in a country where network latency
to your CDNs are really high
53. Iâm in a country where network latency
to your CDNs are really high
How about hosting your own app then?
54. Iâm in a country where network latency
to your CDNs are really high
How about hosting your own app then?*
* in our upcoming SDK release
55. How do I host my own app?
^ these are my app ïŹles
^ this is what my app looks like
56. > expo export
Run this command in your project directory
to dump your app to disk
How do I host my own app?
57. This is what gets dumped to disk
How do I host my own app?
.
âââ android-index.json
âââ ios-index.json
âââ assets
â Â âââ 1ecc2
âââ bundles
   âââ android-01ee6.js
   âââ ios-ee820.js
58. How do I host my own app?
.
âââ android-index.json
âââ ios-index.json
âââ assets
â Â âââ 1ecc2
âââ bundles
   âââ android-01ee6.js
   âââ ios-ee820.js
59. How do I host my own app?
.
âââ android-index.json
âââ ios-index.json
âââ assets
â Â âââ 1ecc2
âââ bundles
   âââ android-01ee6.js
   âââ ios-ee820.js
{bundleUrl: âios-ee820.jsâ}
Big JS bundle
ios-ee820.js
ios-index.json
60. How do I host my own app?
.
âââ android-index.json
âââ ios-index.json
âââ assets
â Â âââ 1ecc2
âââ bundles
   âââ android-01ee6.js
   âââ ios-ee820.js
git push master
61. I pushed to GitHub because it has free static hosting.
You can host your app from any server.
62. How do I build my app binary?
> expo build:ios
Run this command in your project directory
63. How do I build my app binary?
> expo build:ios âpublic-url https://quinlanj.github.io/self-hosting/ios-index.json
Run this command in your project directory
64. How do I build my app binary?
> expo build:ios âpublic-url https://quinlanj.github.io/self-hosting/ios-index.json
{bundleUrl: âios-ee820.jsâ}
Big JS bundle
ios-ee820.js
ios-index.json
^ This ïŹle is served ïŹrst
74. This is what my app looks like.
Iâve installed it on my phone.
75. This is what my app looks like.
Iâve installed it on my phone.
Currently on ïŹlesystem:
JS Bundle
76. This is what my app looks like.
Iâve installed it on my phone.
Currently on ïŹlesystem:
JS Bundle
quinlanj.github.io
Here is the server hosting my app
77. This is what my app looks like.
Iâve installed it on my phone.
Currently on ïŹlesystem:
JS Bundle
quinlanj.github.io
An update is ready!
78. This is what my app looks like.
Iâve installed it on my phone.
Currently on ïŹlesystem:
JS Bundle
quinlanj.github.io
An update is ready!
Files to be served:
New
JS Bundle
79. This is what my app looks like.
Iâve installed it on my phone.
Currently on ïŹlesystem:
JS Bundle
quinlanj.github.io
An update is ready!
Files to be served:
New
JS Bundle
JS Bundle
80. This is what my app looks like.
Iâve installed it on my phone.
Currently on ïŹlesystem:
quinlanj.github.io
An update is ready!
Files to be served:
New
JS Bundle
82. This is what my app looks like.
Iâve installed it on my phone.
Currently on ïŹlesystem:
quinlanj.github.io
An update is ready!
Files to be served:
New
JS Bundle
?
dog.png is pulled down to ïŹlesystem?
86. This is what my app looks like.
Iâve installed it on my phone.
Currently on ïŹlesystem:
quinlanj.github.io
An update is ready!
Files to be served:
New
JS Bundle
?
dog.png is pulled down to ïŹlesystem?
87. This is what my app looks like.
Iâve installed it on my phone.
Currently on ïŹlesystem:
quinlanj.github.io
An update is ready!
Files to be served:
New
JS Bundle
?
dog.png is not on the ïŹlesystem
88. This is what my app looks like.
Iâve installed it on my phone.
Currently on ïŹlesystem:
quinlanj.github.io
An update is ready!
Files to be served:
New
JS Bundle
?
Letâs grab dog.png from server then!
89. This is what my app looks like.
Iâve installed it on my phone.
Currently on ïŹlesystem:
quinlanj.github.io
An update is ready!
Files to be served:
New
JS Bundle
90. This is what my app looks like.
Iâve installed it on my phone.
Currently on ïŹlesystem:
quinlanj.github.io
An update is ready!
Files to be served:
New
JS Bundle
Cached for future use
91. How come assets are stored by hash?
.
âââ android-index.json
âââ ios-index.json
âââ assets
â Â âââ 1ecc2
âââ bundles
   âââ android-01ee6.js
   âââ ios-ee820.js
95. JS Bundle
Module Logic:
Look for 1ecc2 in the ïŹlesystem
If itâs not there, look for 1ecc2 from the server
Actual Implementation
{assetName: âcat.pngâ, hash:â1ecc2â}
97. <Image source={require(âcat1.pngâ} />
<Image source={require(âcrazy-cat.pngâ} />
<Image source={require(âlime-cat.pngâ} />
âŠ
This app displays the same cat picture
These cat pictures are all named something diïŹerent
100. Announcements
We made a web application called Snack
Snack is like a JS Fiddle for react native apps
Snack is now open source, check it out at https://github.com/expo/snack-web