Parcourir la source

Document app launch and the differences between platforms in this regard

Guy Carmeli il y a 5 ans
Parent
révision
1f25ecbe5d
2 fichiers modifiés avec 29 ajouts et 0 suppressions
  1. 1
    0
      docs/_sidebar.md
  2. 28
    0
      docs/docs/app-launch.md

+ 1
- 0
docs/_sidebar.md Voir le fichier

@@ -5,6 +5,7 @@
5 5
   - [Usage](/docs/Usage)
6 6
   - [Showcases](/docs/showcases)
7 7
 - Guide
8
+  - [Launching the App](/docs/app-launch)
8 9
   - [Top Level](/docs/top-level-api)
9 10
   - [Screen](/docs/screen-api)
10 11
   - [Events](/docs/events)

+ 28
- 0
docs/docs/app-launch.md Voir le fichier

@@ -0,0 +1,28 @@
1
+# App Launch
2
+When your app is launched for the first time, the bundle is parsed and executed. At this point you need to show your ui. To do so, Listen to the `appLaunched` event and call `Navigation.setRoot` when the event is received.
3
+
4
+```js
5
+Navigation.events().registerAppLaunchedListener(() => {
6
+  // Each time the event is received we should call Navigation.setRoot
7
+});
8
+```
9
+
10
+!> Register the listener as soon as possible - it should be one of the first lines in your `index.js` file.
11
+If you're observing a "white screen" or a hanging splash screen after relaunching your app, it probably means `Navigation.setRoot` isn't called once the app has launched. Perhaps the listener was registered too late.
12
+
13
+## The difference between the platforms
14
+When your app is launched, RN makes sure Js context is running. Js context is what enables you to execute JavaScript code.
15
+There are a few differences between iOS and Android in this regard
16
+
17
+### iOS
18
+Each time the app moves the the background, Js context is destroyed as the app's process is destroyed.
19
+
20
+### Android
21
+An Android application is typically bound to two contexts:
22
+1. Application - bound to the process
23
+2. Activity - bound to UI
24
+
25
+Js Context is executed and bound to the Application. This means, that even when the Activity is destroyed, Js Context is still executed until the Application (and your process) are destroyed by the system.
26
+
27
+!>*Important!* Because of this, when your app returns to foreground, Js Context might still exist on Android - meaning you might not need to initialise all of your logic, instead you'll only need to call `Navigation.setRoot`.
28
+