Skip to content

Instantly share code, notes, and snippets.

@Klerith
Last active February 6, 2023 20:34
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save Klerith/e6cb4f984cf1bc9c1f2e99b5f5509b7f to your computer and use it in GitHub Desktop.
Save Klerith/e6cb4f984cf1bc9c1f2e99b5f5509b7f to your computer and use it in GitHub Desktop.
TypeScript Snippets
{
// Place your snippets for typescript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Print to console": {
"prefix": "clog",
"body": [
"console.log $1",
],
"description": "Log output to console"
},
"NgRx Actions": {
"prefix": "ngrx-actions",
"body": [
"import { createAction } from '@ngrx/store';",
"",
"export const ${1:increment} = createAction('[${2:Counter Component}] ${1:Increment}');",
],
"description": "Crea las acciones de NgRx"
},
"NgRx Reducer": {
"prefix": "ngrx-reducer",
"body": [
"import { createReducer, on } from '@ngrx/store';",
"import { $2 } from './${1:counter}.actions';",
"",
"export interface State {",
" ${3:key}: ${4:String}; ",
"}",
"",
"export const initialState: State = {",
" ${3:key}: ${5:'hola'},",
"}",
"",
"const _${6:counter}Reducer = createReducer(initialState,",
"",
" on(${2:increment}, state => ({ ...state, ${3:key}: ${5:'hola'}})),",
"",
");",
"",
"export function ${6:counter}Reducer(state, action) {",
" return _${6:counter}Reducer(state, action);",
"}"
],
"description": "Crea el reducer básico"
},
"NgRx App Reducer": {
"prefix": "ngrx-app-reducers",
"body": [
"import { ActionReducerMap } from '@ngrx/store';",
"import * as $1 from './$2.reducer';",
"",
"",
"export interface AppState {",
" ${3:todos}: $4",
"}",
"",
"",
"",
"export const appReducers: ActionReducerMap<AppState> = {",
" ${3:todos}: $5,",
"}",
],
"description": "Crea el AppReducer principal"
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment