DEV: Use the new discourseDebounce function wrapper. (#22)
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
63a8181fa4
commit
3da00ddaa1
|
@ -1,12 +1,22 @@
|
|||
import Component from "@ember/component";
|
||||
import debounce from "discourse/lib/debounce";
|
||||
import { debounce } from "@ember/runloop";
|
||||
import discourseDebounce from "discourse-common/lib/debounce";
|
||||
|
||||
export default Component.extend({
|
||||
classNames: "knowledge-explorer-search",
|
||||
|
||||
debouncedSearch: debounce(function (term) {
|
||||
this.onSearch(term);
|
||||
}, 500),
|
||||
debouncedSearch(term) {
|
||||
// TODO: Use discouseDebounce when discourse 2.7 gets released.
|
||||
const debounceFunc = discourseDebounce || debounce;
|
||||
|
||||
debounceFunc(
|
||||
this,
|
||||
function () {
|
||||
this.onSearch(term);
|
||||
},
|
||||
500
|
||||
);
|
||||
},
|
||||
|
||||
actions: {
|
||||
onSearchTermChange(term) {
|
||||
|
|
Loading…
Reference in New Issue