Skip to content

Instantly share code, notes, and snippets.

@Gid733
Created November 21, 2019 21:01
Show Gist options
  • Save Gid733/caf10759ab4987ab7c00f49e3e989eee to your computer and use it in GitHub Desktop.
Save Gid733/caf10759ab4987ab7c00f49e3e989eee to your computer and use it in GitHub Desktop.
Typescript gist
export const $ACTION_NAME$ = "$ACTION_NAME$";
export const $ACTION_NAME$_SUCCESS = "$ACTION_NAME$_SUCCESS";
export const $ACTION_NAME$_ERROR = "$ACTION_NAME$_ERROR";
// action types
export interface $ACTION_NAME_CLASSIFY$Action {
type: typeof $ACTION_NAME$,
payload: any
}
export interface $ACTION_NAME_CLASSIFY$SuccessAction {
type: typeof $ACTION_NAME$_SUCCESS,
payload: any
}
export interface $ACTION_NAME_CLASSIFY$ErrorAction {
type: typeof $ACTION_NAME$_ERROR,
error: any
}
export type $ACTION_NAMES$Types
= $ACTION_NAME_CLASSIFY$Action | $ACTION_NAME_CLASSIFY$SuccessAction | $ACTION_NAME_CLASSIFY$ErrorAction
// action creators
export function $ACTION_NAME_CAMEL$(payload: any): $ACTION_NAMES$Types {
return {
type: LOGIN_USER,
payload: payload
};
}
export function $ACTION_NAME_CAMEL$Success(payload: any): $ACTION_NAMES$Types {
return {
type: $ACTION_NAMES$_SUCCESS,
payload: payload
};
}
export function $ACTION_NAME_CAMEL$Error(error: any): $ACTION_NAMES$Types {
return {
type: $ACTION_NAMES$_ERROR,
error: error
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment