- added Categories to the Task List.

- Drawer added SubMenu : Personal / Work Todo list categories.
This commit is contained in:
Paolo Arena
2019-01-29 03:12:18 +01:00
parent 0225f27535
commit e029f6165e
13 changed files with 132 additions and 1301 deletions

42
src/classes/debounce.ts Normal file
View File

@@ -0,0 +1,42 @@
/**
* A function that emits a side effect and does not return anything.
*/
export type Procedure = (...args: any[]) => void
export type Options = {
isImmediate: boolean
}
export function debounce<F extends Procedure>(
func: F,
waitMilliseconds: number = 50,
options: Options = {
isImmediate: false
}
): F {
let timeoutId: NodeJS.Timeout | undefined
return function(this: any, ...args: any[]) {
const context = this
const doLater = function() {
timeoutId = undefined
if (!options.isImmediate) {
func.apply(context, args)
}
}
const shouldCallNow = options.isImmediate && timeoutId === undefined
if (timeoutId !== undefined) {
clearTimeout(timeoutId)
}
timeoutId = <any>setTimeout(doLater, waitMilliseconds)
if (shouldCallNow) {
func.apply(context, args)
}
} as any
}