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:
parent
ae271dafad
commit
c6a11d9280
|
@ -2,7 +2,8 @@ import {
|
||||||
default as computed,
|
default as computed,
|
||||||
observes,
|
observes,
|
||||||
} from "discourse-common/utils/decorators";
|
} 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({
|
export default Ember.Component.extend({
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -113,10 +114,19 @@ export default Ember.Component.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes("filter")
|
@observes("filter")
|
||||||
triggerFilter: debounce(function () {
|
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("filteredTables", this.filterTables(this.transformedSchema));
|
||||||
this.set("loading", false);
|
this.set("loading", false);
|
||||||
}, 500),
|
},
|
||||||
|
500
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
@observes("filter")
|
@observes("filter")
|
||||||
setLoading() {
|
setLoading() {
|
||||||
|
|
Loading…
Reference in New Issue