Skip to content

Instantly share code, notes, and snippets.

@mandado
Last active November 17, 2022 15:58
Show Gist options
  • Save mandado/599395707529d19a507050ce63c1d388 to your computer and use it in GitHub Desktop.
Save mandado/599395707529d19a507050ce63c1d388 to your computer and use it in GitHub Desktop.
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)} />
@romulomourao
Copy link

top

@FranciscoCFranco
Copy link

Brabo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment