Skip to content

Instantly share code, notes, and snippets.

@tonymamo
Created July 20, 2020 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonymamo/4fc5ba672d24583a67d34b6a386aa549 to your computer and use it in GitHub Desktop.
Save tonymamo/4fc5ba672d24583a67d34b6a386aa549 to your computer and use it in GitHub Desktop.
{
"FSA Type Creator Name": {
"scope": "javascript,typescript",
"prefix": "fsa",
"body": [
"export const ${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g}_REQUEST = '${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g}_REQUEST';",
"export const ${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g}_SUCCESS = '${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g}_SUCCESS';",
"export const ${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g}_FAILURE = '${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g}_FAILURE';",
"",
"export const ${1} = (payload: ${2}) => ({",
" [RSAA]: {",
" endpoint: ${3},",
" method: '${4}',",
" body: JSON.stringify(payload),",
" types: [",
" ${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g}_REQUEST,",
" ${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g}_SUCCESS,",
" ${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g}_FAILURE,",
" ]",
" },",
"});"
],
"description": "Creates Request, Success, Failure FSA type names"
}
}
{
"FSA Type Creator Name": {
"scope": "javascript,typescript",
"prefix": "fsaType",
"body": [
"export type $1RequestAction = {",
" type: typeof ${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g}_REQUEST;",
"};",
"export type $1SuccessAction = {",
" type: typeof ${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g}_SUCCESS;",
" payload: ${2};",
"};",
"export type $1FailureAction = {",
" type: typeof ${1/([a-z]*)(([A-Z])+([a-z]+))?/${1:/upcase}${2:+_}$3${4:/upcase}/g}_FAILURE;",
"};",
"| $1RequestAction",
"| $1SuccessAction",
"| $1FailureAction"
],
"description": "Creates Request, Success, Failure FSA type names"
}
}
{
"Function Component Snippet": {
"scope": "javascript,typescript",
"prefix": "funcComp",
"body": [
"import React, { FunctionComponent } from 'react';",
"",
"type ${1}Props = {};",
"",
"const ${1}: FunctionComponent<${1}Props> = () => {",
"",
" return (",
" <${2}>",
" ${3}",
" </${2}>",
" );",
"};",
"",
"export default ${1};",
""
],
"description": "Creates Request, Success, Failure FSA type names"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment