Actions

Roughly an action is a plain JS object with a unique type property


        {
            type: ADD_TODO,
            payload: 'Learn NgRx'
        }

        # Proper way
        export const ActionTypes = {
            ADD_TODO: '[Todo] Create Todo',
             // ...
         };
     

Actions describe what happenned (always a verb?)

Action Creators

Roughly a function or a class (more useful for typing purposes)


            /**
            * Every action is comprised of at least a type and an optional
            * payload. Expressing actions as classes enables powerful
            * type checking in reducer functions.
            *
            */
            export class CreateAction implements Action {
            type = ActionTypes.ADD_TODO;
                constructor(public payload: string) { }
            }
         

To factorize & encapsulate the construction => error-proof