TS | Very easy solution | setInterval , clearInterval
Code\n\nfunction cancellable(fn: Function, args: any[], t: number): Function {\n    fn(...args);\n    const intervalId = setInterval(()=>{\n        fn(...args);
# Code\n```\nfunction cancellable(fn: Function, args: any[], t: number): Function {\n    fn(...args);\n    const intervalId = setInterval(()=>{\n        fn(...args);\n    },t);\n\n    const cancelInterval:Function = ()=>{\n        clearInterval(intervalId);\n    }\n    return cancelInterval;\n};\n```
['TypeScript']