Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Action example with TypeScript
export default class UnicornActions {
public static Types = {
ERROR: 'UNICORN_ERROR',
GET_UNICORN: 'GET_UNICORN',
LIKE_UNICORN: 'LIKE_UNICORN',
SUCCESS: 'UNICORN_SUCCESS',
UPDATE_UNICORN: 'UPDATE_UNICORN',
}
public static error = (err: any, actionName: string) => ({
actionName,
error: err,
type: UnicornActions.Types.ERROR,
});
public static done = (data: any, actionName: string) => ({
actionName,
response: data,
type: UnicornActions.Types.SUCCESS
});
public static getUnicorn = (id: string) => ({
id,
type: UnicornActions.Types.GET_UNICORN
});
public static likeUnicorn = (id: string) => ({
id,
type: UnicornActions.Types.LIKE_UNICORN
});
public static updateUnicorn = (id: string, data: any) => ({
data,
id,
type: UnicornActions.Types.UPDATE_UNICORN
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.