TS : Very simple approach | setTimeout, clearTimeout
Code\n```\nfunction cancellable(fn: Function, args: any[], t: number): Function {\n    const timeoutId = setTimeout(()=>{\n        fn(...args)\n    },t);\n\n   
# Code\n```\nfunction cancellable(fn: Function, args: any[], t: number): Function {\n    const timeoutId = setTimeout(()=>{\n        fn(...args)\n    },t);\n\n    const cancelFn:Function = ()=>{\n        clearTimeout(timeoutId);\n    }\n    return cancelFn;\n};\n
['TypeScript']