Skip to content

Instantly share code, notes, and snippets.

@AllGistsEqual
Created February 22, 2021 20:04
Show Gist options
  • Save AllGistsEqual/7568bd8b615a2cea6c54232c29c38504 to your computer and use it in GitHub Desktop.
Save AllGistsEqual/7568bd8b615a2cea6c54232c29c38504 to your computer and use it in GitHub Desktop.
// File: src/redux/ducks/api.ts
export const apiRequest = createAction(
"[API] Request",
(api: ApiRequestPayload<any>) => ({ // eslint-disable-line @typescript-eslint/no-explicit-any
payload: { ...api },
})
)
export const apiSuccess = createAction(
"[API] Success",
(onSuccess: SuccessAction<unknown>, data: unknown) => ({
payload: { onSuccess, data },
})
)
export const apiError = createAction(
"[API] Error",
(onError: ErrorAction, message: string) => ({
payload: { onError, message },
})
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment