Package 

Class HeadlessJsTaskContext


  • 
    public class HeadlessJsTaskContext
    
                        

    Helper class for dealing with JS tasks. Handles per-ReactContext active task tracking, starting / stopping tasks and notifying listeners.

    • Method Detail

      • getInstance

         static HeadlessJsTaskContext getInstance(ReactContext context)

        Get the task helper instance for a particular ReactContext. There is only one instanceper context.

        Note: do not hold long-lived references to the object returned here, asthat will cause memory leaks. Instead, just call this method on-demand.

      • addTaskEventListener

         synchronized void addTaskEventListener(HeadlessJsTaskEventListener listener)

        Register a task lifecycle event listener. Synchronized in order to prevent race conditions withfinishTask, as the listener will be invoked for already running tasks.

      • hasActiveTasks

         boolean hasActiveTasks()

        Get whether there are any running JS tasks at the moment.

      • retryTask

         synchronized boolean retryTask(int taskId)

        Retry a running JS task with a delay. Invokes as long as the process does not getkilled.

      • finishTask

         synchronized void finishTask(int taskId)

        Finish a JS task. Doesn't actually stop the task on the JS side, only removes it from the listof active tasks and notifies listeners. A task can only be finished once.

        Parameters:
        taskId - the unique id returned by startTask.
      • isTaskRunning

         synchronized boolean isTaskRunning(int taskId)

        Check if a given task is currently running. A task is stopped if either finishTask iscalled or it times out.