Last active
November 17, 2022 15:58
-
-
Save mandado/599395707529d19a507050ce63c1d388 to your computer and use it in GitHub Desktop.
This file contains 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
interface CallBack<Params extends any[]> { | |
(...args: Params): void; | |
} | |
export const callAll = | |
<Params extends any[]>(...fns: Array<CallBack<Params> | undefined>) => | |
(...args: Params) => | |
fns.forEach((fn) => typeof fn === 'function' && fn(...args)); | |
// use example <input onKeyDown={callAll(addTagOnEnterPress, removeLastTagOnBackspacePress)} /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
top