MCPcopy
hub / github.com/facebook/react / unstable_scheduleCallback

Function unstable_scheduleCallback

packages/scheduler/src/forks/SchedulerMock.js:330–414  ·  view source on GitHub ↗
(
  priorityLevel: PriorityLevel,
  callback: Callback,
  options?: {delay: number},
)

Source from the content-addressed store, hash-verified

328}
329
330function unstable_scheduleCallback(
331 priorityLevel: PriorityLevel,
332 callback: Callback,
333 options?: {delay: number},
334): Task {
335 var currentTime = getCurrentTime();
336
337 var startTime;
338 if (typeof options === 'object' && options !== null) {
339 var delay = options.delay;
340 if (typeof delay === 'number' && delay > 0) {
341 startTime = currentTime + delay;
342 } else {
343 startTime = currentTime;
344 }
345 } else {
346 startTime = currentTime;
347 }
348
349 var timeout;
350 switch (priorityLevel) {
351 case ImmediatePriority:
352 timeout = IMMEDIATE_PRIORITY_TIMEOUT;
353 break;
354 case UserBlockingPriority:
355 timeout = USER_BLOCKING_PRIORITY_TIMEOUT;
356 break;
357 case IdlePriority:
358 timeout = IDLE_PRIORITY_TIMEOUT;
359 break;
360 case LowPriority:
361 timeout = LOW_PRIORITY_TIMEOUT;
362 break;
363 case NormalPriority:
364 default:
365 timeout = NORMAL_PRIORITY_TIMEOUT;
366 break;
367 }
368
369 var expirationTime = startTime + timeout;
370
371 var newTask: Task = {
372 id: taskIdCounter++,
373 callback,
374 priorityLevel,
375 startTime,
376 expirationTime,
377 sortIndex: -1,
378 };
379 if (enableProfiling) {
380 newTask.isQueued = false;
381 }
382
383 if (startTime > currentTime) {
384 // This is a delayed task.
385 newTask.sortIndex = startTime;
386 push(timerQueue, newTask);
387 if (peek(taskQueue) === null && newTask === peek(timerQueue)) {

Callers

nothing calls this directly

Calls 7

pushFunction · 0.90
peekFunction · 0.90
markTaskStartFunction · 0.90
getCurrentTimeFunction · 0.70
cancelHostTimeoutFunction · 0.70
requestHostTimeoutFunction · 0.70
requestHostCallbackFunction · 0.70

Tested by

no test coverage detected