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

[BUGFIX] Rename private runloop functions #19466

Merged
merged 1 commit into from
Mar 17, 2021
Merged
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getOwner } from '@ember/-internals/owner';
import { backburner } from '@ember/runloop';
import { _backburner } from '@ember/runloop';
import { get } from '@ember/-internals/metal';
import { dasherize } from '@ember/string';
import { HAS_NATIVE_SYMBOL } from '@ember/-internals/utils';
Expand Down Expand Up @@ -364,10 +364,10 @@ export default EmberObject.extend({
this.recordsWatchers.forEach((watcher) => watcher.revalidate());
};

backburner.on('end', this.flushWatchers);
_backburner.on('end', this.flushWatchers);
}
} else if (this.typeWatchers.size === 0 && this.recordsWatchers.size === 0) {
backburner.off('end', this.flushWatchers);
_backburner.off('end', this.flushWatchers);
this.flushWatchers = null;
}
},
Expand All @@ -386,7 +386,7 @@ export default EmberObject.extend({
this.releaseMethods.forEach((fn) => fn());

if (this.flushWatchers) {
backburner.off('end', this.flushWatchers);
_backburner.off('end', this.flushWatchers);
}
},

Expand Down
4 changes: 2 additions & 2 deletions packages/@ember/-internals/glimmer/lib/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getDebugName } from '@ember/-internals/utils';
import { constructStyleDeprecationMessage } from '@ember/-internals/views';
import { assert, deprecate, warn } from '@ember/debug';
import { DeprecationOptions } from '@ember/debug/lib/deprecate';
import { backburner, schedule } from '@ember/runloop';
import { _backburner, schedule } from '@ember/runloop';
import { DEBUG } from '@glimmer/env';
import setGlobalContext from '@glimmer/global-context';
import { EnvironmentDelegate } from '@glimmer/runtime';
Expand All @@ -20,7 +20,7 @@ import toBool from './utils/to-bool';

setGlobalContext({
scheduleRevalidate() {
backburner.ensureInstance();
_backburner.ensureInstance();
},

toBool,
Expand Down
16 changes: 8 additions & 8 deletions packages/@ember/-internals/glimmer/lib/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ENV } from '@ember/-internals/environment';
import { getOwner, Owner } from '@ember/-internals/owner';
import { getViewElement, getViewId } from '@ember/-internals/views';
import { assert } from '@ember/debug';
import { backburner, getCurrentRunLoop } from '@ember/runloop';
import { _backburner, _getCurrentRunLoop } from '@ember/runloop';
import { destroy } from '@glimmer/destroyable';
import { DEBUG } from '@glimmer/env';
import {
Expand Down Expand Up @@ -229,9 +229,9 @@ export function renderSettled() {
renderSettledDeferred = RSVP.defer();
// if there is no current runloop, the promise created above will not have
// a chance to resolve (because its resolved in backburner's "end" event)
if (!getCurrentRunLoop()) {
if (!_getCurrentRunLoop()) {
// ensure a runloop has been kicked off
backburner.schedule('actions', null, K);
_backburner.schedule('actions', null, K);
}
}

Expand All @@ -243,7 +243,7 @@ function resolveRenderPromise() {
let resolve = renderSettledDeferred.resolve;
renderSettledDeferred = null;

backburner.join(null, resolve);
_backburner.join(null, resolve);
}
}

Expand All @@ -258,15 +258,15 @@ function loopEnd() {
throw new Error('infinite rendering invalidation detected');
}
loops++;
return backburner.join(null, K);
return _backburner.join(null, K);
}
}
loops = 0;
resolveRenderPromise();
}

backburner.on('begin', loopBegin);
backburner.on('end', loopEnd);
_backburner.on('begin', loopBegin);
_backburner.on('end', loopEnd);

interface ViewRegistry {
[viewId: string]: unknown;
Expand Down Expand Up @@ -574,7 +574,7 @@ export class Renderer {
}

_scheduleRevalidate(): void {
backburner.scheduleOnce('render', this, this._revalidate);
_backburner.scheduleOnce('render', this, this._revalidate);
}

_isValid(): boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RenderingTestCase, moduleFor, runTask } from 'internal-test-helpers';

import { Component } from '../utils/helpers';
import { getCurrentRunLoop, run } from '@ember/runloop';
import { _getCurrentRunLoop, run } from '@ember/runloop';
import {
subscribe as instrumentationSubscribe,
reset as instrumentationReset,
Expand Down Expand Up @@ -164,7 +164,7 @@ moduleFor(
this.registerComponent('x-foo', {
ComponentClass: Component.extend({
change() {
assert.ok(getCurrentRunLoop(), 'a run loop should have started');
assert.ok(_getCurrentRunLoop(), 'a run loop should have started');
},
}),
template: `<input id="is-done" type="checkbox">`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
subscribe as instrumentationSubscribe,
unsubscribe as instrumentationUnsubscribe,
} from '@ember/instrumentation';
import { getCurrentRunLoop } from '@ember/runloop';
import { _getCurrentRunLoop } from '@ember/runloop';
import { set, computed } from '@ember/-internals/metal';
import { EMBER_IMPROVED_INSTRUMENTATION } from '@ember/canary-features';

Expand Down Expand Up @@ -1019,7 +1019,7 @@ moduleFor(
let OuterComponent = Component.extend({
actions: {
submit() {
capturedRunLoop = getCurrentRunLoop();
capturedRunLoop = _getCurrentRunLoop();
},
},
});
Expand Down
6 changes: 3 additions & 3 deletions packages/@ember/-internals/runtime/lib/ext/rsvp.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as RSVP from 'rsvp';
import { backburner, _rsvpErrorQueue } from '@ember/runloop';
import { _backburner, _rsvpErrorQueue } from '@ember/runloop';
import { getDispatchOverride } from '@ember/-internals/error-handling';
import { assert } from '@ember/debug';

RSVP.configure('async', (callback, promise) => {
backburner.schedule('actions', null, callback, promise);
_backburner.schedule('actions', null, callback, promise);
});

RSVP.configure('after', (cb) => {
backburner.schedule(_rsvpErrorQueue, null, cb);
_backburner.schedule(_rsvpErrorQueue, null, cb);
});

RSVP.on('error', onerrorDefault);
Expand Down
4 changes: 2 additions & 2 deletions packages/@ember/runloop/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Backburner, DeferredActionQueues, Timer } from 'backburner.js';

export const backburner: Backburner;
export const _backburner: Backburner;

export const run = Backburner.run;
export const schedule = Backburner.schedule;
Expand All @@ -9,7 +9,7 @@ export const join = Backburner.join;
export const cancel = Backburner.cancel;
export const scheduleOnce = Backburner.scheduleOnce;

export function getCurrentRunLoop(): DeferredActionQueues;
export function _getCurrentRunLoop(): DeferredActionQueues;

export function once(method: Function): Timer;
export function once<T, U extends keyof T>(target: T, method: U, ...args): Timer;
Expand Down
54 changes: 27 additions & 27 deletions packages/@ember/runloop/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { flushAsyncObservers } from '@ember/-internals/metal';
import Backburner from 'backburner';

let currentRunLoop = null;
export function getCurrentRunLoop() {
export function _getCurrentRunLoop() {
return currentRunLoop;
}

Expand Down Expand Up @@ -40,7 +40,7 @@ export const _rsvpErrorQueue = `${Math.random()}${Date.now()}`.replace('.', '');
@default ['actions', 'destroy']
@private
*/
export const queues = [
export const _queues = [
'actions',

// used in router transitions to prevent unnecessary loading state entry
Expand All @@ -56,7 +56,7 @@ export const queues = [
_rsvpErrorQueue,
];

export const backburner = new Backburner(queues, {
export const _backburner = new Backburner(_queues, {
defaultQueue: 'actions',
onBegin,
onEnd,
Expand Down Expand Up @@ -101,7 +101,7 @@ export const backburner = new Backburner(queues, {
@public
*/
export function run() {
return backburner.run(...arguments);
return _backburner.run(...arguments);
}

/**
Expand Down Expand Up @@ -149,7 +149,7 @@ export function run() {
@public
*/
export function join() {
return backburner.join(...arguments);
return _backburner.join(...arguments);
}

/**
Expand Down Expand Up @@ -259,7 +259,7 @@ export const bind = (...curried) => {
@public
*/
export function begin() {
backburner.begin();
_backburner.begin();
}

/**
Expand All @@ -282,7 +282,7 @@ export function begin() {
@public
*/
export function end() {
backburner.end();
_backburner.end();
}

/**
Expand Down Expand Up @@ -327,17 +327,17 @@ export function end() {
@public
*/
export function schedule(/* queue, target, method */) {
return backburner.schedule(...arguments);
return _backburner.schedule(...arguments);
}

// Used by global test teardown
export function hasScheduledTimers() {
return backburner.hasTimers();
export function _hasScheduledTimers() {
return _backburner.hasTimers();
}

// Used by global test teardown
export function cancelTimers() {
backburner.cancelTimers();
export function _cancelTimers() {
_backburner.cancelTimers();
}

/**
Expand Down Expand Up @@ -371,7 +371,7 @@ export function cancelTimers() {
@public
*/
export function later(/*target, method*/) {
return backburner.later(...arguments);
return _backburner.later(...arguments);
}

/**
Expand All @@ -391,7 +391,7 @@ export function later(/*target, method*/) {
*/
export function once(...args) {
args.unshift('actions');
return backburner.scheduleOnce(...args);
return _backburner.scheduleOnce(...args);
}

/**
Expand Down Expand Up @@ -467,7 +467,7 @@ export function once(...args) {
@public
*/
export function scheduleOnce(/* queue, target, method*/) {
return backburner.scheduleOnce(...arguments);
return _backburner.scheduleOnce(...arguments);
}

/**
Expand Down Expand Up @@ -542,7 +542,7 @@ export function scheduleOnce(/* queue, target, method*/) {
*/
export function next(...args) {
args.push(1);
return backburner.later(...args);
return _backburner.later(...args);
}

/**
Expand Down Expand Up @@ -613,7 +613,7 @@ export function next(...args) {
@public
*/
export function cancel(timer) {
return backburner.cancel(timer);
return _backburner.cancel(timer);
}

/**
Expand Down Expand Up @@ -691,7 +691,7 @@ export function cancel(timer) {
@public
*/
export function debounce() {
return backburner.debounce(...arguments);
return _backburner.debounce(...arguments);
}

/**
Expand Down Expand Up @@ -738,7 +738,7 @@ export function debounce() {
@public
*/
export function throttle() {
return backburner.throttle(...arguments);
return _backburner.throttle(...arguments);
}

export let _deprecatedGlobalGetCurrentRunLoop;
Expand Down Expand Up @@ -780,46 +780,46 @@ if (DEBUG) {
}
);

return getCurrentRunLoop();
return _getCurrentRunLoop();
};

defineDeprecatedRunloopFunc('backburner', backburner);
defineDeprecatedRunloopFunc('backburner', _backburner);
defineDeprecatedRunloopFunc('begin', begin);
defineDeprecatedRunloopFunc('bind', bind);
defineDeprecatedRunloopFunc('cancel', cancel);
defineDeprecatedRunloopFunc('debounce', debounce);
defineDeprecatedRunloopFunc('end', end);
defineDeprecatedRunloopFunc('hasScheduledTimers', hasScheduledTimers);
defineDeprecatedRunloopFunc('hasScheduledTimers', _hasScheduledTimers);
defineDeprecatedRunloopFunc('join', join);
defineDeprecatedRunloopFunc('later', later);
defineDeprecatedRunloopFunc('next', next);
defineDeprecatedRunloopFunc('once', once);
defineDeprecatedRunloopFunc('schedule', schedule);
defineDeprecatedRunloopFunc('scheduleOnce', scheduleOnce);
defineDeprecatedRunloopFunc('throttle', throttle);
defineDeprecatedRunloopFunc('cancelTimers', cancelTimers);
defineDeprecatedRunloopFunc('cancelTimers', _cancelTimers);
Object.defineProperty(run, 'currentRunLoop', {
get: _deprecatedGlobalGetCurrentRunLoop,
enumerable: false,
});
} else {
run.backburner = backburner;
run.backburner = _backburner;
run.begin = begin;
run.bind = bind;
run.cancel = cancel;
run.debounce = debounce;
run.end = end;
run.hasScheduledTimers = hasScheduledTimers;
run.hasScheduledTimers = _hasScheduledTimers;
run.join = join;
run.later = later;
run.next = next;
run.once = once;
run.schedule = schedule;
run.scheduleOnce = scheduleOnce;
run.throttle = throttle;
run.cancelTimers = cancelTimers;
run.cancelTimers = _cancelTimers;
Object.defineProperty(run, 'currentRunLoop', {
get: getCurrentRunLoop,
get: _getCurrentRunLoop,
enumerable: false,
});
}
Loading