DEV: Wrap Ember.run.debounce. (#11352)

We want to wrap the `Ember.run.debounce` function and internally call `Ember.run` instead when running tests.

This commit changes discourseDebounce to work the same way as `Ember.run.debounce`.

Now that `discourseDebounce` works exactly like `Ember.run.debounce`, let's replace it and only use `DiscourseDebounce` from now on.

Move debounce to discourse-common to be able to reuse it in different bundles

Keep old debounce file for backwards-compatibility
This commit is contained in:
Roman Rizzi
2020-12-10 11:01:42 -03:00
committed by GitHub
parent fb2e24a77a
commit 8b426431a4
50 changed files with 519 additions and 353 deletions

View File

@@ -1,8 +1,9 @@
import { debounce, schedule } from "@ember/runloop";
import Component from "@ember/component";
import discourseDebounce from "discourse-common/lib/debounce";
import loadScript from "discourse/lib/load-script";
import { makeArray } from "discourse-common/lib/helpers";
import { number } from "discourse/lib/formatter";
import { schedule } from "@ember/runloop";
export default Component.extend({
classNames: ["admin-report-chart"],
@@ -14,7 +15,7 @@ export default Component.extend({
this._super(...arguments);
this.resizeHandler = () =>
debounce(this, this._scheduleChartRendering, 500);
discourseDebounce(this, this._scheduleChartRendering, 500);
},
didInsertElement() {
@@ -34,7 +35,7 @@ export default Component.extend({
didReceiveAttrs() {
this._super(...arguments);
debounce(this, this._scheduleChartRendering, 100);
discourseDebounce(this, this._scheduleChartRendering, 100);
},
_scheduleChartRendering() {