MCPcopy Create free account
hub / github.com/plotly/dash / unstable_scheduleCallback

Function unstable_scheduleCallback

dash/deps/react@18.2.0.js:2752–2833  ·  view source on GitHub ↗
(priorityLevel, callback, options)

Source from the content-addressed store, hash-verified

2750 }
2751
2752 function unstable_scheduleCallback(priorityLevel, callback, options) {
2753 var currentTime = getCurrentTime();
2754 var startTime;
2755
2756 if (typeof options === 'object' && options !== null) {
2757 var delay = options.delay;
2758
2759 if (typeof delay === 'number' && delay > 0) {
2760 startTime = currentTime + delay;
2761 } else {
2762 startTime = currentTime;
2763 }
2764 } else {
2765 startTime = currentTime;
2766 }
2767
2768 var timeout;
2769
2770 switch (priorityLevel) {
2771 case ImmediatePriority:
2772 timeout = IMMEDIATE_PRIORITY_TIMEOUT;
2773 break;
2774
2775 case UserBlockingPriority:
2776 timeout = USER_BLOCKING_PRIORITY_TIMEOUT;
2777 break;
2778
2779 case IdlePriority:
2780 timeout = IDLE_PRIORITY_TIMEOUT;
2781 break;
2782
2783 case LowPriority:
2784 timeout = LOW_PRIORITY_TIMEOUT;
2785 break;
2786
2787 case NormalPriority:
2788 default:
2789 timeout = NORMAL_PRIORITY_TIMEOUT;
2790 break;
2791 }
2792
2793 var expirationTime = startTime + timeout;
2794 var newTask = {
2795 id: taskIdCounter++,
2796 callback: callback,
2797 priorityLevel: priorityLevel,
2798 startTime: startTime,
2799 expirationTime: expirationTime,
2800 sortIndex: -1
2801 };
2802
2803 if (startTime > currentTime) {
2804 // This is a delayed task.
2805 newTask.sortIndex = startTime;
2806 push(timerQueue, newTask);
2807
2808 if (peek(taskQueue) === null && newTask === peek(timerQueue)) {
2809 // All tasks are delayed, and this is the task with the earliest delay.

Callers 3

Calls 6

getCurrentTimeFunction · 0.85
pushFunction · 0.70
peekFunction · 0.70
cancelHostTimeoutFunction · 0.70
requestHostTimeoutFunction · 0.70
requestHostCallbackFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…