Last active
June 9, 2022 20:08
-
-
Save turtlepile/f75a7c40941e424de0b340a1b4a42246 to your computer and use it in GitHub Desktop.
debounce function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loadEntries: _.debounce(function (searchInput) { | |
this.customerSearchLoading = true; | |
this.externalUserItems = []; | |
this.customers = []; | |
if (searchInput != null && searchInput.length > 2) { | |
const accountFormData = { | |
SearchText: searchInput, | |
CanikId: searchInput, | |
}; | |
axios({ | |
method: "post", | |
url: "GetExternalAccounts", | |
data: qs.stringify(accountFormData), | |
headers: { | |
"Content-Type": "application/x-www-form-urlencoded", | |
Accept: "application/json", | |
}, | |
}) | |
.then((response) => { | |
if (response.data == "NOK") { | |
this.externalUserItems = []; | |
this.customers = []; | |
this.customerSearchLoading = false; | |
console.log(this.customers); | |
} else { | |
this.customerSearchLoading = false; | |
this.externalUserItems = response.data; | |
this.customers = response.data; | |
} | |
}) | |
.catch(() => { | |
this.customerSearchLoading = false; | |
this.externalUserItems = []; | |
this.customers = []; | |
}); | |
} else { | |
this.customerSearchLoading = false; | |
} | |
}, 500), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import _ from "lodash";
//https://css-tricks.com/debouncing-throttling-explained-examples/ -tugba