public class HeadlessJsTaskContext
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
void |
addTaskEventListener(HeadlessJsTaskEventListener listener)
Register a task lifecycle event listener.
|
void |
finishTask(int taskId)
Finish a JS task.
|
static HeadlessJsTaskContext |
getInstance(ReactContext context)
Get the task helper instance for a particular
ReactContext. |
boolean |
hasActiveTasks()
Get whether there are any running JS tasks at the moment.
|
boolean |
isTaskRunning(int taskId)
Check if a given task is currently running.
|
void |
removeTaskEventListener(HeadlessJsTaskEventListener listener)
Unregister a task lifecycle event listener.
|
int |
startTask(HeadlessJsTaskConfig taskConfig)
Start a JS task.
|
public static HeadlessJsTaskContext getInstance(ReactContext context)
ReactContext. There is only one instance
per context.
Note: do not hold long-lived references to the object returned here, as that will cause memory leaks. Instead, just call this method on-demand.
public void addTaskEventListener(HeadlessJsTaskEventListener listener)
public void removeTaskEventListener(HeadlessJsTaskEventListener listener)
public boolean hasActiveTasks()
public int startTask(HeadlessJsTaskConfig taskConfig)
AppRegistry.startHeadlessTask(int, java.lang.String, com.facebook.react.bridge.WritableMap) and notifying
listeners.public void finishTask(int taskId)
taskId - the unique id returned by startTask(com.facebook.react.jstasks.HeadlessJsTaskConfig).public boolean isTaskRunning(int taskId)
finishTask(int) is
called or it times out.