Schematics
This repository contains schematics for generating NGXS Store in Angular apps using the Angular CLI.
Installation
Install Angular CLI
You should be using @angular/cli@6.1.0
or newer.
npm i -g @angular/cli
Install NGXS Schematics
npm i -g @ngxs/schematics
Usage
Creating a new project
To generate new Angular project with NGXS Store, you can use ng new
with @ngxs/schematics
specified as the schematics collection.
ng new --collection=@ngxs/schematics my-app
Create a NGXS Store
To generate store with @ngxs/schematics
:
ng generate @ngxs/schematics:store --name todo
Result:
CREATE src/todo/todo.actions.tsCREATE src/todo/todo.state.ts
Or with spec:
ng generate @ngxs/schematics:store --name todo --spec
Result:
CREATE src/todo/todo.actions.tsCREATE src/todo/todo.state.spec.tsCREATE src/todo/todo.state.ts
Create a NGXS State
To generate state with @ngxs/schematics
:
ng generate @ngxs/schematics:state --name todo
Result:
CREATE src/todo/todo.state.ts
Or with spec:
ng generate @ngxs/schematics:state --name todo --spec
Result:
CREATE src/todo/todo.state.spec.tsCREATE src/todo/todo.state.ts
Create a NGXS Actions
To generate state with @ngxs/schematics
:
ng generate @ngxs/schematics:actions --name todo
Result:
CREATE src/todo/todo.actions.ts
NGXS Starter Kit
Usage
To generate store with @ngxs/schematics:starter-kit
:
ng generate @ngxs/schematics:starter-kit
Result:
CREATE src/store/store.config.tsCREATE src/store/store.module.tsCREATE src/store/auth/auth.actions.tsCREATE src/store/auth/auth.state.tsCREATE src/store/auth/model/auth.model.tsCREATE src/store/dashboard/index.tsCREATE src/store/dashboard/states/dictionary/dictionary.actions.tsCREATE src/store/dashboard/states/dictionary/dictionary.state.tsCREATE src/store/dashboard/states/dictionary/model/dictionary-response.model.tsCREATE src/store/dashboard/states/user/user.actions.tsCREATE src/store/dashboard/states/user/user.state.tsCREATE src/store/dashboard/states/user/model/person.model.ts
Or with spec:
ng generate @ngxs/schematics:starter-kit --spec
Result:
CREATE src/store/store.config.tsCREATE src/store/store.module.tsCREATE src/store/auth/auth.actions.tsCREATE src/store/auth/auth.state.spec.tsCREATE src/store/auth/auth.state.tsCREATE src/store/auth/model/auth.model.tsCREATE src/store/dashboard/index.tsCREATE src/store/dashboard/states/dictionary/dictionary.actions.tsCREATE src/store/dashboard/states/dictionary/dictionary.state.spec.tsCREATE src/store/dashboard/states/dictionary/dictionary.state.tsCREATE src/store/dashboard/states/dictionary/model/dictionary-response.model.tsCREATE src/store/dashboard/states/user/user.actions.tsCREATE src/store/dashboard/states/user/user.state.spec.tsCREATE src/store/dashboard/states/user/user.state.tsCREATE src/store/dashboard/states/user/model/person.model.ts