DefinitelyTyped/types/scheduler/index.d.ts
Maurice de Beijer b5d9f57930 Add unstable_next() to the React scheduler (#38974)
* Add unstable_next to the React scheduler

* Apply suggestions from code review

Co-Authored-By: Nathan Bierema <nbierema@gmail.com>

* Update tests with aditional undefined result type

* No undefined because errors aren't caught and bubble up
2019-10-15 11:40:14 -07:00

33 lines
1.5 KiB
TypeScript

// Type definitions for scheduler 0.16
// Project: https://reactjs.org/
// Definitions by: Nathan Bierema <https://github.com/Methuselah96>
// Sebastian Silbermann <https://github.com/eps1lon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
export type FrameCallbackType = () => FrameCallbackType | void;
export interface CallbackNode {
callback: FrameCallbackType;
priorityLevel: number;
expirationTime: number;
next: CallbackNode | null;
prev: CallbackNode | null;
}
export const unstable_ImmediatePriority = 1;
export const unstable_UserBlockingPriority = 2;
export const unstable_NormalPriority = 3;
export const unstable_IdlePriority = 5;
export const unstable_LowPriority = 4;
export function unstable_runWithPriority<T>(priorityLevel: number, eventHandler: () => T): T;
export function unstable_scheduleCallback(priorityLevel: number, callback: FrameCallbackType, options?: { delay?: number, timeout?: number}): CallbackNode;
export function unstable_next<T>(eventHandler: () => T): T;
export function unstable_cancelCallback(callbackNode: CallbackNode): void;
export function unstable_wrapCallback(callback: FrameCallbackType): () => FrameCallbackType;
export function unstable_getCurrentPriorityLevel(): number;
export function unstable_shouldYield(): boolean;
export function unstable_continueExecution(): void;
export function unstable_pauseExecution(): void;
export function unstable_getFirstCallbackNode(): CallbackNode | null;
export function unstable_now(): number;