Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 06220a5

Browse files
fixed snippets form reducer and actions
1 parent 7e756d9 commit 06220a5

File tree

1 file changed

+64
-64
lines changed

1 file changed

+64
-64
lines changed

‎snippets/typescript.json‎

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
"body": [
66
"import { Action } from '@ngrx/store';",
77
"",
8-
"export const ${1:ACTION_CONST} = \"${2:ACTION_STR}\"",
9-
"export const ${1}_SUCCESS = \"${2} SUCCESS\"",
10-
"export const ${1}_FAIL = \"${2} FAIL\"",
8+
"export const ${1:ACTION_CONST} = \"${1/[\\_]/ /g}\"",
9+
"export const ${1}_SUCCESS = \"${1/[\\_]/ /g} SUCCESS\"",
10+
"export const ${1}_FAIL = \"${1/[\\_]/ /g} FAIL\"",
1111
"",
12-
"export class ${3:ActionCreator} implements Action {",
12+
"export class ${2:ActionCreator} implements Action {",
1313
"\treadonly type = ${1};",
1414
"\tconstructor() { }",
1515
"}\n",
16-
"export class ${3}Success implements Action {",
16+
"export class ${2}Success implements Action {",
1717
"\treadonly type = ${1}_SUCCESS;",
1818
"\tconstructor(public payload: any) { }",
1919
"}\n",
20-
"export class ${3}Fail implements Action {",
20+
"export class ${2}Fail implements Action {",
2121
"\treadonly type = ${1}_FAIL;",
2222
"\tconstructor(public payload: any) { }",
2323
"}\n",
24-
"export type ${3}Action = ${3} | ${3}Success | ${3}Fail;"
24+
"export type Actions = ${2} | ${2}Success | ${2}Fail;"
2525
]
2626
},
2727
"NgRx Actions CRUD Setup": {
@@ -30,95 +30,95 @@
3030
"body": [
3131
"import { Action } from '@ngrx/store';",
3232
"",
33-
"export const LOAD_${1:ACTION_CONST} = \"LOAD ${2:ACTION_STR}\"",
34-
"export const LOAD_${1}_SUCCESS = \"LOAD ${2} SUCCESS\"",
35-
"export const LOAD_${1}_FAIL = \"LOAD ${2} FAIL\"",
33+
"export const ${1:ACTION_CONST} = \"${1/[\\_]/ /g}\"",
34+
"export const ${1}_SUCCESS = \"${1/[\\_]/ /g} SUCCESS\"",
35+
"export const ${1}_FAIL = \"${1/[\\_]/ /g} FAIL\"",
3636
"",
37-
"export class Load${3:ActionCreator} implements Action {",
38-
"\treadonly type = LOAD_${1};",
37+
"export class Load${2:ActionCreator} implements Action {",
38+
"\treadonly type = ${1};",
3939
"}\n",
40-
"export class Load${3}Success implements Action {",
41-
"\treadonly type = LOAD_${1}_SUCCESS;",
40+
"export class Load${2}Success implements Action {",
41+
"\treadonly type = ${1}_SUCCESS;",
4242
"\tconstructor(public payload: any) { }",
4343
"}\n",
44-
"export class Load${3}Fail implements Action {",
45-
"\treadonly type = LOAD_${1}_FAIL;",
44+
"export class Load${2}Fail implements Action {",
45+
"\treadonly type = ${1}_FAIL;",
4646
"\tconstructor(public payload: any) { }",
4747
"}",
4848
"",
49-
"export const CREATE_${1:ACTION_CONST} = \"CREATE ${2:ACTION_STR}\"",
50-
"export const CREATE_${1}_SUCCESS = \"CREATE ${2} SUCCESS\"",
51-
"export const CREATE_${1}_FAIL = \"CREATE ${2} FAIL\"",
49+
"export const CREATE_${3:ACTION_CONST} = \"CREATE ${3}\"",
50+
"export const CREATE_${3}_SUCCESS = \"CREATE ${3} SUCCESS\"",
51+
"export const CREATE_${3}_FAIL = \"CREATE ${3} FAIL\"",
5252
"",
53-
"export class Create${3:ActionCreator} implements Action {",
54-
"\treadonly type = CREATE_${1};",
53+
"export class Create${4:ActionCreator} implements Action {",
54+
"\treadonly type = CREATE_${3};",
5555
"\tconstructor(public payload: any) { }",
5656
"}\n",
57-
"export class Create${3}Success implements Action {",
58-
"\treadonly type = CREATE_${1}_SUCCESS;",
57+
"export class Create${4}Success implements Action {",
58+
"\treadonly type = CREATE_${3}_SUCCESS;",
5959
"\tconstructor(public payload: any) { }",
6060
"}\n",
61-
"export class Create${3}Fail implements Action {",
62-
"\treadonly type = CREATE_${1}_FAIL;",
61+
"export class Create${4}Fail implements Action {",
62+
"\treadonly type = CREATE_${3}_FAIL;",
6363
"\tconstructor(public payload: any) { }",
6464
"}",
6565
"",
66-
"export const UPDATE_${1:ACTION_CONST} = \"UPDATE ${2:ACTION_STR}\"",
67-
"export const UPDATE_${1}_SUCCESS = \"UPDATE ${2} SUCCESS\"",
68-
"export const UPDATE_${1}_FAIL = \"UPDATE ${2} FAIL\"",
66+
"export const UPDATE_${3} = \"UPDATE ${3}\"",
67+
"export const UPDATE_${3}_SUCCESS = \"UPDATE ${3} SUCCESS\"",
68+
"export const UPDATE_${3}_FAIL = \"UPDATE ${3} FAIL\"",
6969
"",
70-
"export class Update${3:ActionCreator} implements Action {",
71-
"\treadonly type = UPDATE_${1};",
70+
"export class Update${4} implements Action {",
71+
"\treadonly type = UPDATE_${3};",
7272
"\tconstructor(public payload: any) { }",
7373
"}\n",
74-
"export class Update${3}Success implements Action {",
75-
"\treadonly type = UPDATE_${1}_SUCCESS;",
74+
"export class Update${4}Success implements Action {",
75+
"\treadonly type = UPDATE_${3}_SUCCESS;",
7676
"\tconstructor(public payload: any) { }",
7777
"}\n",
78-
"export class Update${3}Fail implements Action {",
79-
"\treadonly type = UPDATE_${1}_FAIL;",
78+
"export class Update${4}Fail implements Action {",
79+
"\treadonly type = UPDATE_${3}_FAIL;",
8080
"\tconstructor(public payload: any) { }",
8181
"}",
8282
"",
83-
"export const DELETE_${1:ACTION_CONST} = \"DELETE ${2:ACTION_STR}\"",
84-
"export const DELETE_${1}_SUCCESS = \"DELETE ${2} SUCCESS\"",
85-
"export const DELETE_${1}_FAIL = \"DELETE ${2} FAIL\"",
83+
"export const DELETE_${3} = \"DELETE ${3:ACTION_STR}\"",
84+
"export const DELETE_${3}_SUCCESS = \"DELETE ${3} SUCCESS\"",
85+
"export const DELETE_${3}_FAIL = \"DELETE ${3} FAIL\"",
8686
"",
87-
"export class Delete${3:ActionCreator} implements Action {",
88-
"\treadonly type = DELETE_${1};",
87+
"export class Delete${4:ActionCreator} implements Action {",
88+
"\treadonly type = DELETE_${3};",
8989
"\tconstructor(public id: number) { }",
9090
"}\n",
91-
"export class Delete${3}Success implements Action {",
92-
"\treadonly type = DELETE_${1}_SUCCESS;",
91+
"export class Delete${4}Success implements Action {",
92+
"\treadonly type = DELETE_${3}_SUCCESS;",
9393
"\tconstructor(public payload: any) { }",
9494
"}\n",
95-
"export class Delete${3}Fail implements Action {",
96-
"\treadonly type = DELETE_${1}_FAIL;",
95+
"export class Delete${4}Fail implements Action {",
96+
"\treadonly type = DELETE_${3}_FAIL;",
9797
"\tconstructor(public payload: any) { }",
9898
"}",
9999
"",
100-
"export type ${3}Action =",
101-
"| Load${3}",
102-
"| Load${3}Success",
103-
"| Load${3}Fail",
104-
"| Create${3}",
105-
"| Create${3}Success",
106-
"| Create${3}Fail",
107-
"| Update${3}",
108-
"| Update${3}Success",
109-
"| Update${3}Fail",
110-
"| Delete${3}",
111-
"| Delete${3}Success",
112-
"| Delete${3}Fail;",
100+
"export type Actions =",
101+
"\t| Load${2}",
102+
"\t| Load${2}Success",
103+
"\t| Load${2}Fail",
104+
"\t| Create${4}",
105+
"\t| Create${4}Success",
106+
"\t| Create${4}Fail",
107+
"\t| Update${4}",
108+
"\t| Update${4}Success",
109+
"\t| Update${4}Fail",
110+
"\t| Delete${4}",
111+
"\t| Delete${4}Success",
112+
"\t| Delete${4}Fail;",
113113
""
114114
]
115115
},
116116
"NgRx Basic Action": {
117117
"prefix": "ngrx-action",
118118
"description": "NgRx action constant and creator.",
119119
"body": [
120-
"export const ${1:ACTION_CONST} = \"${2:ACTION_STR}\"\n",
121-
"export class ${3:ActionCreator} implements Action {",
120+
"export const ${1:ACTION_CONST} = \"${1/[\\_]/ /g}\"\n",
121+
"export class ${2:ActionCreator} implements Action {",
122122
"\treadonly type = ${1};",
123123
"\tconstructor() { }",
124124
"}\n"
@@ -128,8 +128,8 @@
128128
"prefix": "ngrx-action-success",
129129
"description": "NgRx action constant and creator as success",
130130
"body": [
131-
"export const ${1:ACTION_CONST}_SUCCESS = \"${2:ACTION_STR}\"\n",
132-
"export class ${3:ActionCreator}Success implements Action {",
131+
"export const ${1:ACTION_CONST}_SUCCESS = \"${1/[\\_]/ /g} SUCCESS\"\n",
132+
"export class ${2:ActionCreator}Success implements Action {",
133133
"\treadonly type = ${1}_SUCCESS;",
134134
"\tconstructor(public payload: any) { }",
135135
"}\n"
@@ -139,7 +139,7 @@
139139
"prefix": "ngrx-action-fail",
140140
"description": "NgRx action constant and creator as fail.",
141141
"body": [
142-
"export const ${1:ACTION_CONST}_FAIL = \"${2:ACTION_STR}\"\n",
142+
"export const ${1:ACTION_CONST}_FAIL = \"${1/[\\_]/ /g} FAIL\"\n",
143143
"export class ${3:ActionCreator} implements Action {",
144144
"\treadonly type = ${1}_FAIL;",
145145
"\tconstructor(public payload: any) { }",
@@ -202,9 +202,9 @@
202202
"export const intialState = {",
203203
"\t//set intial state",
204204
"};",
205-
"export function ${3:name}Reducer(state = intialState, action: ${2}.${4:AllActions}) {",
205+
"export function ${3:name}Reducer(state = intialState, action: ${2}${4:AllActions}) {",
206206
"\tswitch (action.type) {",
207-
"\t\tcase ${2}.${5:ACTION_TYPE}: {",
207+
"\t\tcase ${2}${5:ACTION_TYPE}: {",
208208
"\t\t\t//add your code",
209209
"\t\t\treturn { ...state };",
210210
"\t\t}",
@@ -219,7 +219,7 @@
219219
"prefix": "ngrx-case",
220220
"description": "NgRx Reducer Switch Case",
221221
"body": [
222-
"case ${1:alias}.${2:ACTION_TYPE}: {",
222+
"case ${1:alias}${2:ACTION_TYPE}: {",
223223
"\t//add your code",
224224
"\t\treturn { ...state };",
225225
"\t}",

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /