Created
September 20, 2018 23:24
-
-
Save TracyNgot/9152ad6a2b01708161f197744bd2f2ab to your computer and use it in GitHub Desktop.
Action example with TypeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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