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

Function unstable_scheduleCallback

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

Source from the content-addressed store, hash-verified

325}
326
327function unstable_scheduleCallback(
328 priorityLevel: PriorityLevel,
329 callback: Callback,
330 options?: {delay: number},
331): Task {
332 var currentTime = getCurrentTime();
333
334 var startTime;
335 if (typeof options === 'object' && options !== null) {
336 var delay = options.delay;
337 if (typeof delay === 'number' && delay > 0) {
338 startTime = currentTime + delay;
339 } else {
340 startTime = currentTime;
341 }
342 } else {
343 startTime = currentTime;
344 }
345
346 var timeout;
347 switch (priorityLevel) {
348 case ImmediatePriority:
349 // Times out immediately
350 timeout = -1;
351 break;
352 case UserBlockingPriority:
353 // Eventually times out
354 timeout = userBlockingPriorityTimeout;
355 break;
356 case IdlePriority:
357 // Never times out
358 timeout = maxSigned31BitInt;
359 break;
360 case LowPriority:
361 // Eventually times out
362 timeout = lowPriorityTimeout;
363 break;
364 case NormalPriority:
365 default:
366 // Eventually times out
367 timeout = normalPriorityTimeout;
368 break;
369 }
370
371 var expirationTime = startTime + timeout;
372
373 var newTask: Task = {
374 id: taskIdCounter++,
375 callback,
376 priorityLevel,
377 startTime,
378 expirationTime,
379 sortIndex: -1,
380 };
381 if (enableProfiling) {
382 newTask.isQueued = false;
383 }
384

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