AppRegistry
AppRegistry is the JS entry point to running all React Native apps. App root components should register themselves with AppRegistry.registerComponent, then the native system can load the bundle for the app and then actually run the app when it's ready by invoking AppRegistry.runApplication.
To "stop" an application when a view should be destroyed, call AppRegistry.unmountApplicationComponentAtRootTag with the tag that was passed into runApplication. These should always be used as a pair.
AppRegistry should be required early in the require sequence to make sure the JS execution environment is setup before other modules are required.
Reference
Methods
setWrapperComponentProvider()
Parameters:
| Name | Type | Required |
|---|---|---|
| provider | ComponentProvider | yes |
enableArchitectureIndicator()
Parameters:
| Name | Type | Required |
|---|---|---|
| enabled | boolean | yes |
registerConfig()
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
| config | AppConfig | yes | See below. |
Valid AppConfig keys are:
- 'appKey' (string)- Required.
- 'component' (ComponentProvider) - Optional.
- 'run' (Function) - Optional.
- 'section' (boolean) - Optional.
registerComponent()
Parameters:
| Name | Type | Required |
|---|---|---|
| appKey | string | yes |
| componentProvider | ComponentProvider | yes |
| section | boolean | no |
registerRunnable()
Parameters:
| Name | Type | Required |
|---|---|---|
| appKey | string | yes |
| run | Function | yes |
registerSection()
Parameters:
| Name | Type | Required |
|---|---|---|
| appKey | string | yes |
| component | ComponentProvider | yes |
getAppKeys()
Returns an Array of AppKeys
getSectionKeys()
Returns an Array of SectionKeys
getSections()
Returns all Runnables which is an object with key of AppKeys and value of type of Runnable which consist of:
- 'component' (ComponentProvider).
- 'run' (Function).
getRunnable()
Returns a Runnable object which consist of:
- 'component' (ComponentProvider).
- 'run' (Function).
getRegistry()
Returns a type Registry which consist of:
- 'sections' (Array of strings).
- 'runnables' (Runnables).
setComponentProviderInstrumentationHook()
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
| hook | Function | yes | See below. |
A valid hook accepts the following as arguments:
- 'component' (ComponentProvider)- Required.
- 'scopedPerformanceLogger' (IPerformanceLogger)- Required.
The hook function returns a React Component
runApplication()
Loads the JavaScript bundle and runs the app.
Parameters:
| Name | Type | Required |
|---|---|---|
| appKey | string | yes |
| appParameters | any | yes |
unmountApplicationComponentAtRootTag()
Stops an application when a view should be destroyed.
Parameters:
| Name | Type | Required |
|---|---|---|
| rootTag | number | yes |
registerHeadlessTask()
Register a headless task. A headless task is a bit of code that runs without a UI. @param taskKey the key associated with this task @param taskProvider a promise returning function that takes some data passed from the native side as the only argument; when the promise is resolved or rejected the native side is notified of this event and it may decide to destroy the JS context.
This is a way to run tasks in JavaScript while your app is in the background. It can be used, for example, to sync fresh data, handle push notifications, or play music.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
| taskKey | String | yes | See below. |
| taskProvider | TaskProvider | yes | See below. |
- A valid
TaskProvideris a function that returns aTask. - A
Taskis a function that accepts any data as argument and returns a Promise that resolves to undefined.
registerCancellableHeadlessTask()
Register a headless task which can be cancelled. A headless task is a bit of code that runs without a UI. @param taskKey the key associated with this task @param taskProvider a promise returning function that takes some data passed from the native side as the only argument; when the promise is resolved or rejected the native side is notified of this event and it may decide to destroy the JS context. @param taskCancelProvider a void returning function that takes no arguments; when a cancellation is requested, the function being executed by taskProvider should wrap up and return ASAP.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
| taskKey | String | yes | See below. |
| taskProvider | TaskProvider | yes | See below. |
| taskCancelProvider | TaskCancelProvider | yes | See below. |
- A valid
TaskProvideris a function that returns aTask. - A
Taskis a function that accepts any data as argument and returns a Promise that resolves to undefined. - A valid
TaskCancelProvideris a function that returns aTaskCanceller. - A
TaskCancelleris a function that accepts no argument and returns void.
startHeadlessTask()
Only called from native code. Starts a headless task.
@param taskId the native id for this task instance to keep track of its execution @param taskKey the key for the task to start @param data the data to pass to the task
Parameters:
| Name | Type | Required |
|---|---|---|
| taskId | number | yes |
| taskKey | string | yes |
| data | any | yes |
cancelHeadlessTask()
Only called from native code. Cancels a headless task.
@param taskId the native id for this task instance that was used when startHeadlessTask was called @param taskKey the key for the task that was used when startHeadlessTask was called
Parameters:
| Name | Type | Required |
|---|---|---|
| taskId | number | yes |
| taskKey | string | yes |