How to use the @ngrx/router-store.ROUTER_CANCEL function in @ngrx/router-store

To help you get started, we’ve selected a few @ngrx/router-store examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SAP / cloud-commerce-spartacus-storefront / projects / core / src / routing / store / reducers / router.reducer.spec.ts View on Github external
it('should clear next state', () => {
        const { initialState } = fromReducer;
        const beforeState = { ...initialState, nextState: initialState.state };
        const action = {
          ...templateAction,
          type: fromNgrxRouter.ROUTER_CANCEL,
        };
        const state = fromReducer.reducer(beforeState, action);
        expect(state.nextState).toBe(undefined);
      });
    });
github SAP / cloud-commerce-spartacus-storefront / projects / core / src / routing / store / reducers / router.reducer.ts View on Github external
export function reducer(
  state: RouterState = initialState,
  action: any
): RouterState {
  switch (action.type) {
    case fromNgrxRouter.ROUTER_NAVIGATION: {
      return {
        ...state,
        nextState: action.payload.routerState,
        navigationId: action.payload.event.id,
      };
    }

    case fromNgrxRouter.ROUTER_ERROR:
    case fromNgrxRouter.ROUTER_CANCEL: {
      return {
        ...state,
        nextState: undefined,
      };
    }

    case fromNgrxRouter.ROUTER_NAVIGATED: {
      return {
        state: action.payload.routerState,
        navigationId: action.payload.event.id,
        nextState: undefined,
      };
    }

    default: {
      return state;