|
436 | 436 | "description": "RxJs import",
|
437 | 437 | "body": ["import { ${1:map} } from 'rxjs/operators';", "$0"]
|
438 | 438 | },
|
439 |
| - "NgRx Data Module": { |
440 |
| - "prefix": "a-ngrx-data-store-module", |
441 |
| - "description": "NgRx Data Store Module", |
| 439 | + "Angular Resolver": { |
| 440 | + "prefix": "a-resolver", |
| 441 | + "description": "Angular Resolver", |
| 442 | + "body": [ |
| 443 | + "import { Injectable } from '@angular/core';", |
| 444 | + "import { Resolve, ActivatedRouteSnapshot } from '@angular/router';", |
| 445 | + "import { Observable } from 'rxjs';", |
| 446 | + "", |
| 447 | + "@Injectable({ providedIn: 'root' })", |
| 448 | + "export class ${1:YourResolver} implements Resolve<${2:ObjectToResolve}> {", |
| 449 | + "\tresolve(route: ActivatedRouteSnapshot): Observable<${2:ObjectToResolve}> | Promise<${2:ObjectToResolve}> | ${2:ObjectToResolve} {", |
| 450 | + "\t\treturn ${0};", |
| 451 | + "\t}", |
| 452 | + "}" |
| 453 | + ] |
| 454 | + }, |
| 455 | + "NgRx Store Module": { |
| 456 | + "prefix": "a-ngrx-store-module", |
| 457 | + "description": "NgRx Store Module", |
442 | 458 | "body": [
|
443 | 459 | "import { NgModule } from '@angular/core';",
|
444 | 460 | "import { EffectsModule } from '@ngrx/effects';",
|
445 | 461 | "import { StoreModule } from '@ngrx/store';",
|
446 | 462 | "import { StoreDevtoolsModule } from '@ngrx/store-devtools';",
|
447 |
| - "import { NgrxDataModule } from 'ngrx-data';", |
448 | 463 | "import { environment } from '../../environments/environment';",
|
449 |
| - "import { entityConfig } from './entity-metadata';", |
450 | 464 | "",
|
451 | 465 | "@NgModule({",
|
452 | 466 | " imports: [",
|
453 | 467 | " StoreModule.forRoot({}),",
|
454 | 468 | " EffectsModule.forRoot([]),",
|
455 |
| - " environment.production ? [] : StoreDevtoolsModule.instrument(),", |
456 |
| - " NgrxDataModule.forRoot(entityConfig)", |
| 469 | + " environment.production ? [] : StoreDevtoolsModule.instrument()", |
457 | 470 | " ]",
|
458 | 471 | "})",
|
459 |
| - "export class AppStoreModule {}" |
| 472 | + "export class $1StoreModule {}" |
| 473 | + ] |
| 474 | + }, |
| 475 | + "NgRx Create Action": { |
| 476 | + "prefix": "a-ngrx-create-action", |
| 477 | + "description": "Creates an NgRx Action", |
| 478 | + "body": [ |
| 479 | + "export const ${1:action} = createAction('[${2:Source}] ${3:Event}');" |
| 480 | + ] |
| 481 | + }, |
| 482 | + "NgRx Create Action w/ Props": { |
| 483 | + "prefix": "a-ngrx-create-action-props", |
| 484 | + "description": "Creates an NgRx Action with Props", |
| 485 | + "body": [ |
| 486 | + "export const ${1:action} = createAction('[${2:Source}] ${3:Event}', props<{${4:key}: ${5:type}}>());" |
| 487 | + ] |
| 488 | + }, |
| 489 | + "NgRx Create Reducer": { |
| 490 | + "prefix": "a-ngrx-create-reducer", |
| 491 | + "description": "Creates an NgRx Reducer", |
| 492 | + "body": [ |
| 493 | + "const ${1:feature}Reducer = createReducer(", |
| 494 | + "\tintialState,", |
| 495 | + "\ton($1Actions.action, state => ({ ...state, ${2:prop}: ${3:updatedValue} })),", |
| 496 | + ");", |
| 497 | + "", |
| 498 | + "export function reducer(state: State | undefined: action: Action) {", |
| 499 | + "\treturn $1Reducer(state, action);", |
| 500 | + "}" |
| 501 | + ] |
| 502 | + }, |
| 503 | + "NgRx Create Effect": { |
| 504 | + "prefix": "a-ngrx-create-effect", |
| 505 | + "description": "Creates an NgRx Effect", |
| 506 | + "body": [ |
| 507 | + "${1:effectName}$ = createEffect(() => this.actions$.pipe(", |
| 508 | + "\tofType(${2:action}.type),", |
| 509 | + "\t/** An EMPTY observable only emits completion. Replace with your own observable stream */", |
| 510 | + "\t${3:operator}(() => ${4:EMPTY})", |
| 511 | + "\t)", |
| 512 | + ");" |
| 513 | + ] |
| 514 | + }, |
| 515 | + "NgRx Create Effect for API Call": { |
| 516 | + "prefix": "a-ngrx-create-effect-api", |
| 517 | + "description": "Creates an NgRx Effect Scaffolded for API Call", |
| 518 | + "body": [ |
| 519 | + "${1:effectName}$ = createEffect(() => this.actions$.pipe(", |
| 520 | + "\tofType(${2:Feature}Actions.${3:action}.type),", |
| 521 | + "\t${4:operator}(() =>", |
| 522 | + "\t\t${5:apiSource}.pipe(", |
| 523 | + "\t\t\tmap(data => $2Actions.$3Success({ data })),", |
| 524 | + "\t\t\tcatchError(error => of($2Actions.$3Failure({ error }))))", |
| 525 | + "\t\t)", |
| 526 | + "\t)", |
| 527 | + ");" |
| 528 | + ] |
| 529 | + }, |
| 530 | + "NgRx Create Selector": { |
| 531 | + "prefix": "a-ngrx-create-selector", |
| 532 | + "description": "Creates an NgRx Selector", |
| 533 | + "body": [ |
| 534 | + "export const select${1:Feature}${2:Property} = createSelector(", |
| 535 | + "\tselect$1,", |
| 536 | + "\t(state: $1State) => state.${3:property}", |
| 537 | + ");" |
| 538 | + ] |
| 539 | + }, |
| 540 | + "NgRx Create Selector w/ Props": { |
| 541 | + "prefix": "a-ngrx-create-selector-props", |
| 542 | + "description": "Creates an NgRx Selector using props", |
| 543 | + "body": [ |
| 544 | + "export const select${1:Feature}${2:Property} = createSelector(", |
| 545 | + "\tselect$1,", |
| 546 | + "\t(state: $1State, props) => ${3:selectLogic}", |
| 547 | + ");" |
460 | 548 | ]
|
461 | 549 | },
|
| 550 | + "NgRx Data Import Entity Data Module": { |
| 551 | + "prefix": "a-ngrx-data-entity-data-module-import", |
| 552 | + "description": "Import NgRx Entity Data Module", |
| 553 | + "body": ["EntityDataModule.forRoot(${1:entityConfig})"] |
| 554 | + }, |
462 | 555 | "NgRx Data Entity Metadata": {
|
463 | 556 | "prefix": "a-ngrx-data-entity-metadata",
|
464 | 557 | "description": "NgRx Data Entity Metadata",
|
465 | 558 | "body": [
|
466 |
| - "import { EntityMetadataMap } from 'ngrx-data';", |
| 559 | + "import { EntityMetadataMap } from '@ngrx/data';", |
467 | 560 | "",
|
468 | 561 | "const entityMetadata: EntityMetadataMap = {",
|
469 | 562 | " ${1:Model1}: {},${0}",
|
|
482 | 575 | "import {",
|
483 | 576 | " EntityCollectionServiceBase,",
|
484 | 577 | " EntityCollectionServiceElementsFactory",
|
485 |
| - "} from 'ngrx-data';", |
| 578 | + "} from '@ngrx/data';", |
486 | 579 | "import { ${1:Model} } from '${2:../core}';",
|
487 | 580 | "",
|
488 | 581 | "@Injectable({ providedIn: 'root' })",
|
|
492 | 585 | " }",
|
493 | 586 | "}"
|
494 | 587 | ]
|
495 |
| - }, |
496 |
| - "Angular Resolver": { |
497 |
| - "prefix": "a-resolver", |
498 |
| - "description": "Angular Resolver", |
499 |
| - "body": [ |
500 |
| - "import { Injectable } from '@angular/core';", |
501 |
| - "import { Resolve, ActivatedRouteSnapshot } from '@angular/router';", |
502 |
| - "import { Observable } from 'rxjs';", |
503 |
| - "", |
504 |
| - "@Injectable({ providedIn: 'root' })", |
505 |
| - "export class ${1:YourResolver} implements Resolve<${2:ObjectToResolve}> {", |
506 |
| - "\tresolve(route: ActivatedRouteSnapshot): Observable<${2:ObjectToResolve}> | Promise<${2:ObjectToResolve}> | ${2:ObjectToResolve} {", |
507 |
| - "\t\treturn ${0};", |
508 |
| - "\t}", |
509 |
| - "}" |
510 |
| - ] |
511 | 588 | }
|
512 | 589 | }
|
0 commit comments