AppRegistry
AppRegistry所有 React Native 应用的 JS 入口。应用的根组件应当通过AppRegistry.registerComponent方法注册自己,然后原生系统才可以加载应用的代码包并且在启动完成之后通过调用AppRegistry.runApplication来真正运行应用。
要“结束”一个应用并销毁视图的话,请调用AppRegistry.unmountApplicationComponentAtRootTag方法,参数为在runApplication中使用的标签名。它们必须严格匹配。
AppRegistry应当在require序列中尽可能早的被 require 到,以确保 JS 运行环境在其它模块之前被准备好。
文档
方法
setWrapperComponentProvider()
static setWrapperComponentProvider(provider)
registerConfig()
static registerConfig(config)
registerComponent()
static registerComponent(appKey, componentProvider, section?)
registerRunnable()
static registerRunnable(appKey, run)
registerSection()
static registerSection(appKey, component)
getAppKeys()
static getAppKeys()
getSectionKeys()
static getSectionKeys()
getSections()
static getSections()
getRunnable()
static getRunnable(appKey)
getRegistry()
static getRegistry()
setComponentProviderInstrumentationHook()
static setComponentProviderInstrumentationHook(hook)
runApplication()
static runApplication(appKey, appParameters)
unmountApplicationComponentAtRootTag()
static unmountApplicationComponentAtRootTag(rootTag)
registerHeadlessTask()
static registerHeadlessTask(taskKey, taskProvider)
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.
registerCancellableHeadlessTask()
static registerCancellableHeadlessTask(taskKey, taskProvider, taskCancelProvider)
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.
startHeadlessTask()
static startHeadlessTask(taskId, taskKey, data)
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
cancelHeadlessTask()
static cancelHeadlessTask(taskId, taskKey)
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