import { Action } from '@ngrx/store'; import { NavigationExtras } from '@angular/router'; /** * For each action type in an action group, make a simple * enum object for all of this group's action types. */ export enum RouterActionTypes { Go = '[Router] Go', Back = '[Router] Back', Forward = '[Router] Forward' } /** * Every action is comprised of at least a type and an optional * payload. Expressing actions as classes enables powerful * type checking in reducer functions. */ interface RoutePayload { path: any[]; query?: object; extras?: NavigationExtras; } export class Go implements Action { readonly type = RouterActionTypes.Go; constructor(public payload: RoutePayload) {} } export class Back implements Action { readonly type = RouterActionTypes.Back; } export class Forward implements Action { readonly type = RouterActionTypes.Forward; } /** * Export a type alias of all actions in this action group * so that reducers can easily compose action types */ export type RouterActions = Go | Back | Forward;