Simplifying param to getScheduleFn
MODIFY
addon/scheduler.js
addon/scheduler.js
@@ -10,10 +10,7 @@ let _whenRouteIdle;
let _requestAnimationFrameEnabled;
let _requestIdleCallbackEnabled;
let _activeScheduledTasks = 0;
-export const SCHEDULE_TYPE = {
- RAF: 'requestAnimationFrame',
- RIC: 'requestIdleCallback',
-};
+export const REQUEST_IDLE_CALLBACK = 'requestIdleCallback';
export const SIMPLE_CALLBACK = callback => callback();
reset();
@@ -25,7 +22,7 @@ export function beginTransition() {
_afterNextPaint(getScheduleFn())
);
_whenRouteIdle = _whenRoutePainted.then(() =>
- _afterNextPaint(getScheduleFn(SCHEDULE_TYPE.RIC))
+ _afterNextPaint(getScheduleFn(REQUEST_IDLE_CALLBACK))
);
}
}
@@ -130,7 +127,7 @@ if (DEBUG) {
}
export function getScheduleFn(scheduleType) {
- if (scheduleType == SCHEDULE_TYPE.RIC && _requestIdleCallbackEnabled) {
+ if (scheduleType == REQUEST_IDLE_CALLBACK && _requestIdleCallbackEnabled) {
return requestIdleCallback;
} else if (_requestAnimationFrameEnabled) {
return requestAnimationFrame;

MODIFY
tests/unit/scheduler-test.js
tests/unit/scheduler-test.js
@@ -10,7 +10,7 @@ import {
useRequestAnimationFrame,
useRequestIdleCallback,
getScheduleFn,
- SCHEDULE_TYPE,
+ REQUEST_IDLE_CALLBACK,
SIMPLE_CALLBACK,
} from 'ember-app-scheduler/scheduler';
@@ -82,13 +82,13 @@ module('Unit | Scheduler', function(hooks) {
});
test('getScheduleFn returns correct scheduleFn for requestIdleCallback', function(assert) {
- assert.equal(getScheduleFn(SCHEDULE_TYPE.RIC), requestIdleCallback);
+ assert.equal(getScheduleFn(REQUEST_IDLE_CALLBACK), requestIdleCallback);
});
test('getScheduleFn falls back to requestAnimationFrame if requestIdleCallback not available', function(assert) {
useRequestIdleCallback(false);
- assert.equal(getScheduleFn(SCHEDULE_TYPE.RIC), requestAnimationFrame);
+ assert.equal(getScheduleFn(REQUEST_IDLE_CALLBACK), requestAnimationFrame);
});
test('getScheduleFn returns simple callback if requestAnimationFrame not available', function(assert) {

Simplifying param to getScheduleFn