Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[size: tiny] Rename methods exposed by ReactScheduler #12742

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-art/src/ReactART.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ const ARTRenderer = ReactFiberReconciler({
return emptyObject;
},

scheduleDeferredCallback: ReactScheduler.rIC,
scheduleDeferredCallback: ReactScheduler.scheduleSerialCallback,

shouldSetTextContent(type, props) {
return (
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/client/ReactDOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,8 @@ const DOMRenderer = ReactFiberReconciler({
},
},

scheduleDeferredCallback: ReactScheduler.rIC,
cancelDeferredCallback: ReactScheduler.cIC,
scheduleDeferredCallback: ReactScheduler.scheduleSerialCallback,
cancelDeferredCallback: ReactScheduler.cancelScheduledCallback,
});

ReactGenericBatching.injection.injectRenderer(DOMRenderer);
Expand Down
18 changes: 9 additions & 9 deletions packages/react-scheduler/src/ReactScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ if (hasNativePerformanceNow) {
}

// TODO: There's no way to cancel, because Fiber doesn't atm.
let rIC: (
let scheduleSerialCallback: (
callback: (deadline: Deadline, options?: {timeout: number}) => void,
) => number;
let cIC: (callbackID: number) => void;
let cancelScheduledCallback: (callbackID: number) => void;

if (!ExecutionEnvironment.canUseDOM) {
rIC = function(
scheduleSerialCallback = function(
frameCallback: (deadline: Deadline, options?: {timeout: number}) => void,
): number {
return setTimeout(() => {
Expand All @@ -81,7 +81,7 @@ if (!ExecutionEnvironment.canUseDOM) {
});
});
};
cIC = function(timeoutID: number) {
cancelScheduledCallback = function(timeoutID: number) {
clearTimeout(timeoutID);
};
} else {
Expand Down Expand Up @@ -186,7 +186,7 @@ if (!ExecutionEnvironment.canUseDOM) {
}
};

rIC = function(
scheduleSerialCallback = function(
callback: (deadline: Deadline) => void,
options?: {timeout: number},
): number {
Expand All @@ -199,19 +199,19 @@ if (!ExecutionEnvironment.canUseDOM) {
if (!isAnimationFrameScheduled) {
// If rAF didn't already schedule one, we need to schedule a frame.
// TODO: If this rAF doesn't materialize because the browser throttles, we
// might want to still have setTimeout trigger rIC as a backup to ensure
// that we keep performing work.
// might want to still have setTimeout trigger scheduleSerialCallback as a
// backup to ensure that we keep performing work.
isAnimationFrameScheduled = true;
requestAnimationFrame(animationTick);
}
return 0;
};

cIC = function() {
cancelScheduledCallback = function() {
scheduledRICCallback = null;
isIdleScheduled = false;
timeoutTime = -1;
};
}

export {now, rIC, cIC};
export {now, scheduleSerialCallback, cancelScheduledCallback};
6 changes: 3 additions & 3 deletions packages/react-scheduler/src/__tests__/ReactScheduler-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ describe('ReactScheduler', () => {
ReactScheduler = require('react-scheduler');
});

it('rIC calls the callback within the frame when not blocked', () => {
const {rIC} = ReactScheduler;
it('scheduleSerialCallback calls the callback within the frame when not blocked', () => {
const {scheduleSerialCallback} = ReactScheduler;
const cb = jest.fn();
rIC(cb);
scheduleSerialCallback(cb);
jest.runAllTimers();
expect(cb.mock.calls.length).toBe(1);
// should have ... TODO details on what we expect
Expand Down