Isolate Netlify, Firebase and Helper functions + Import from absolute paths

This commit is contained in:
Liyas Thomas
2020-06-21 09:24:45 +05:30
parent 24315ab0e6
commit 5d94ac361e
56 changed files with 108 additions and 112 deletions

15
helpers/utils/debounce.js Normal file
View File

@@ -0,0 +1,15 @@
// Debounce is a higher order function which makes its enclosed function be executed
// only if the function wasn't called again till 'delay' time has passed, this helps reduce impact of heavy working
// functions which might be called frequently
// NOTE : Don't use lambda functions as this doesn't get bound properly in them, use the 'function (args) {}' format
const debounce = (func, delay) => {
let inDebounce
return function () {
const context = this
const args = arguments
clearTimeout(inDebounce)
inDebounce = setTimeout(() => func.apply(context, args), delay)
}
}
export default debounce