Skip to content

Instantly share code, notes, and snippets.

@binjospookie
Created October 27, 2020 15:47
Show Gist options
  • Save binjospookie/87baaa131081998a6e4735aaa141c291 to your computer and use it in GitHub Desktop.
Save binjospookie/87baaa131081998a6e4735aaa141c291 to your computer and use it in GitHub Desktop.
const addExternalProcessingData = declareAction<Record<string, unknown>>();
const EVENTS = {
[EVENT_NAME.ADD_PROCESSING_DATA]: addExternalProcessingData,
} as const;
const makeCall = (store: Store) => ({
name,
payload,
}: {
readonly name: string;
readonly payload: unknown;
}): boolean => {
const action = EVENTS[name];
if (!action || !isActionCreator(action)) {
return false;
}
store.dispatch(action(payload));
return true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment