Last active
February 3, 2021 15:51
-
-
Save JeffryGonzalez/5a81436f89445a3979c2d0536712cbd3 to your computer and use it in GitHub Desktop.
ngrx snippets
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
{ | |
"NGRX Root Reducer": { | |
"prefix": "ngrootreducer", | |
"body": [ | |
"import { ActionReducerMap } from '@ngrx/store';", | |
"", | |
"export interface $1 {", | |
"", | |
"}", | |
"", | |
"export const reducers: ActionReducerMap<$1> = {", | |
"", | |
"};", | |
"$0" | |
], | |
"description": "Root Reducer for NGRX Store" | |
}, | |
"NGRX Reducer": { | |
"prefix": "ngrxreducer", | |
"body": [ | |
"import { EntityState, createEntityAdapter } from '@ngrx/entity';", | |
"import { createReducer, Action } from '@ngrx/store';", | |
"", | |
"export interface ${1:EntityInterface} {", | |
"", | |
"}", | |
"", | |
"export interface ${2:State} extends EntityState<$1> {", | |
"", | |
"}", | |
"", | |
"export const adapter = createEntityAdapter<$1>();", | |
"", | |
"const initialState = adapter.getInitialState();", | |
"", | |
"const reducerFunction = createReducer(", | |
" initialState", | |
");", | |
"", | |
"export function reducer(state: $2 = initialState, action: Action): $2 {", | |
" return reducerFunction(state, action);", | |
"}", | |
"", | |
"", | |
"", | |
"" | |
], | |
"description": "A branch reducer" | |
}, | |
"NGRX Empty Action": { | |
"prefix": "ngrxactionempty", | |
"body": [ | |
"export const ${1:actionCreator} = createAction(", | |
" '[${2:feature}] ${3:action name}'", | |
");" | |
], | |
"description": "An Empty Action" | |
}, | |
"NGRX Props Action": { | |
"prefix": "ngrxactionprops", | |
"body": [ | |
"export const ${1:actionCreator} = createAction(", | |
" '[${2:feature}] ${3:action name}',", | |
" props<{${0:props}}>()", | |
");" | |
], | |
"description": "An Action With Properties" | |
}, | |
"NGRX Function Action": { | |
"prefix": "ngrxactionfunction", | |
"body": [ | |
"export const ${1:actionCreator} = createAction(", | |
" '[${2:feature}] ${3:action name}',", | |
" ({${4:args}}: { ${5:interface}}) => ({", | |
" $0", | |
"})", | |
");" | |
], | |
"description": "An Action With Function" | |
}, | |
"jasmine describe": { | |
"prefix": "desc", | |
"body": [ | |
"describe('${1:what}', () => {\r", | |
"\r$0", | |
"});" | |
], | |
"description": "jasmine describe" | |
}, | |
"jasmine it": { | |
"prefix": "it", | |
"body": [ | |
" it('${1:what}', () => {\r", | |
" $0\r", | |
" });" | |
], | |
"description": "jasmine it" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment