|
174 | 174 | "}\n" |
175 | 175 | ] |
176 | 176 | }, |
177 | | - "NgRx Effects Setup": { |
178 | | - "prefix": "ngrx-effect-setup", |
179 | | - "description": "NgRx effect setup", |
| 177 | + "NgRx Create Effect Setup": { |
| 178 | + "prefix": "ngrx-create-effect-setup", |
| 179 | + "description": "NgRx create effect setup", |
180 | 180 | "body": [ |
181 | 181 | "import { Injectable } from '@angular/core';", |
182 | 182 | "import { Actions, createEffect, ofType } from '@ngrx/effects';", |
|
204 | 204 | "}" |
205 | 205 | ] |
206 | 206 | }, |
207 | | - "NgRx Effect": { |
208 | | - "prefix": "ngrx-effect", |
209 | | - "description": "NgRx effect", |
| 207 | + "NgRx Create Effect": { |
| 208 | + "prefix": "ngrx-create-effect", |
| 209 | + "description": "NgRx create effect", |
210 | 210 | "body": [ |
211 | 211 | "${1:effectName}$ = createEffect(() =>", |
212 | 212 | "\tthis.actions$.pipe(", |
|
221 | 221 | ");" |
222 | 222 | ] |
223 | 223 | }, |
| 224 | + "NgRx Effects Setup": { |
| 225 | + "prefix": "ngrx-effect-setup", |
| 226 | + "description": "NgRx effect setup", |
| 227 | + "body": [ |
| 228 | + "import { Injectable } from '@angular/core';", |
| 229 | + "import { Actions, Effect, ofType } from '@ngrx/effects';", |
| 230 | + "", |
| 231 | + "// import { of } from 'rxjs';", |
| 232 | + "import { catchError, map, switchMap } from 'rxjs/operators';", |
| 233 | + "", |
| 234 | + "import * as ${2:alias} from '${1:actions}';", |
| 235 | + "//import all requried services or any dependencies", |
| 236 | + "", |
| 237 | + "@Injectable()", |
| 238 | + "export class ${3:Name}Effects {", |
| 239 | + "\tconstructor(private action$: Actions) { }", |
| 240 | + "", |
| 241 | + "\t@Effect()", |
| 242 | + "\t${4:effectName}$ = this.action$.pipe(", |
| 243 | + "\t\tofType(${2}${5:ACTION_TYPE}),", |
| 244 | + "\t\tswitchMap(() => {", |
| 245 | + "\t\t\t/*return this.myService().pipe(", |
| 246 | + "\t\t\t\tmap(data => data),", |
| 247 | + "\t\t\t\tcatchError(error => of(error))", |
| 248 | + "\t\t\t\t//dispatch action with payload in `map`", |
| 249 | + "\t\t\t\t//dispatch action with error in `catchError`", |
| 250 | + "\t\t\t);*/", |
| 251 | + "\t\t})", |
| 252 | + "\t);", |
| 253 | + "}" |
| 254 | + ] |
| 255 | + }, |
| 256 | + "NgRx Effect": { |
| 257 | + "prefix": "ngrx-effect", |
| 258 | + "description": "NgRx effect", |
| 259 | + "body": [ |
| 260 | + "@Effect()", |
| 261 | + "${1:effectName}$ = this.action$.pipe(", |
| 262 | + "\tofType(${2:ACTION_TYPE}),", |
| 263 | + "\tswitchMap(() => {", |
| 264 | + "\t\t/*return this.myService().pipe(", |
| 265 | + "\t\t\tmap(data => data),", |
| 266 | + "\t\t\tcatchError(error => error)", |
| 267 | + "\t\t);*/", |
| 268 | + "\t})", |
| 269 | + ");" |
| 270 | + ] |
| 271 | + }, |
224 | 272 | "NgRx Root Effect Registration": { |
225 | 273 | "prefix": "ngrx-root-effect-registration", |
226 | 274 | "description": "NgRx Root Effect Registration.\nimport { EffectsModule } from '@ngrx/effects';", |
|
0 commit comments