Generating actions

Do this by typing the following:

ng generate action jedis

It will generate an actions file for us called jedi.actions.ts with the following content:

// jedis.actions.ts

import { Action } from '@ngrx/store';

export enum JedisActionTypes {
JedisAction = '[Jedis] Action'
}

export class Jedis implements Action {
readonly type = JediActionTypes.JediAction;
}

export type JediActions = Jedi;

The preceding code gives us nice scaffolded files with some nice defaults and it creates a enum type that we can use in conjunction with reducers and selectors. Looking at the preceding code, we realize that we need to extend JedisActionTypes if we want things such as ADD, CREATE, and other CRUD operations.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.188.27