1
0
mirror of synced 2026-08-06 10:26:57 +00:00

DEV: Use the new discourseDebounce function wrapper. (#85)

We recently merged a Discourse core's PR to replace usages of Ember's debounce and discourseDebounce with a new debounce wrapper. The new wrapper works exactly like Ember's debounce but internally calls "run" when called in test mode.

This PR replaces all usages of other debounce functions with the new wrapper and fallbacks to Ember's debounce for backward-compatibility.
This commit is contained in:
Roman Rizzi
2021-01-05 13:09:21 -03:00
committed by GitHub
parent ae271dafad
commit c6a11d9280
@@ -2,7 +2,8 @@ import {
default as computed,
observes,
} from "discourse-common/utils/decorators";
import debounce from "discourse/lib/debounce";
import discourseDebounce from "discourse-common/lib/debounce";
import debounce from "@ember/runloop";
export default Ember.Component.extend({
actions: {
@@ -113,10 +114,19 @@ export default Ember.Component.extend({
},
@observes("filter")
triggerFilter: debounce(function () {
this.set("filteredTables", this.filterTables(this.transformedSchema));
this.set("loading", false);
}, 500),
triggerFilter() {
// TODO: Use discouseDebounce after the 2.7 release.
let debounceFunc = discourseDebounce || debounce;
debounceFunc(
this,
function () {
this.set("filteredTables", this.filterTables(this.transformedSchema));
this.set("loading", false);
},
500
);
},
@observes("filter")
setLoading() {