require(["esri/core/scheduling"], function(scheduling) { /* code goes here */ });
Object: esri/core/scheduling
Since: ArcGIS API for JavaScript 4.7

Various utilities and convenience functions for executing code at various phases of browser frames. The scheduling module allows you to register tasks that are executed in every animation frame. This can be used to synchronize updates with ongoing animations of the view, or to animate the view manually by adjusting the extent or camera in every frame.

// Animate the scene view camera heading in every frame
var handle = scheduling.addFrameTask({
  update: function() {
    var camera = view.camera.clone();
    camera.heading += 0.2;
    view.camera = camera;
  }
});

// Remove frame task as soon as the user starts interacting
// in the view
watchUtils.whenOnce(view, "interacting", function() {
  handle.remove();
});

Method Overview

NameReturn TypeSummaryObject
FrameTaskHandle

Registers a frame task.

more details
more detailsscheduling
Object

Schedules the execution of a callback function at the next web browser tick.

more details
more detailsscheduling

Method Details

addFrameTask(phases){FrameTaskHandle}static

Registers a frame task. An animation frame is composed of different phases to let various actors execute code before, after, or during the rendering of MapView or SceneView.

Parameter:

The callbacks for each phase of the frame.

Returns:
TypeDescription
FrameTaskHandleA handle to remove, pause, or resume the frame task.
Example:
// Animate the scene view camera heading in every frame
var handle = scheduling.addFrameTask({
  update: function() {
    var camera = view.camera.clone();
    camera.heading += 0.2;
    view.camera = camera;
  }
});

// Remove frame task as soon as the user starts interacting
// in the view
watchUtils.whenOnce(view, "interacting", function() {
  handle.remove();
});
schedule(callback){Object}static

Schedules the execution of a callback function at the next web browser tick. Unlike addFrameTask, a scheduled callback will only run once. Scheduling a task for the next execution tick can be useful when you want to throttle/accumulate functionality over a single javascript execution context.

Parameter:
callback Function

The function to call at the next tick.

Returns:
TypeDescription
ObjectReturns an scheduling handler with a remove() method that can be called to prevent the callback to be called at the next tick.
PropertyTypeDescription
removeFunctionWhen called, removes the callback from the callbacks queue.
Example:
// Use scheduling.schedule to log an error message at most once per tick
var logErrorHandle;

function logError(error) {
  if (!logErrorHandle) {
    logErrorHandle = scheduling.schedule(function() {
      console.error(error);
      logErrorHandle = null;
    });
  }
});

Type Definitions

FrameTaskHandleObject

An object to remove or pause a frame task registered with addFrameTask().

Properties:
pause Function

Pause the execution the frame task at every frame.

resume Function

Resumes the execution the frame task.

remove Function

Removes the frame task.

PhaseCallback(event)

A function called at a specific phase of the animation frame.

Parameter:
optional

An object with timing information.

PhaseCallbacksObject

A set of callbacks that will be called at specific phases of the animation frame.

Properties:
optional

A callback called before rendering.

optional

A callback to execute rendering logic.

optional

A callback to execute state update logic.

PhaseEventObject

An object with timing information.

Properties:
time Number

The absolute time at the start of the current animation frame.

deltaTime Number

The elapsed time since the last animation frame.

elapsedFrameTime Number

The amount of time spent within the current animation frame. This can be used for budgeting (e.g. some tasks may already have run).

API Reference search results

NameTypeModule
Loading...