How to use the @ngrx/router-store.ROUTER_NAVIGATED 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 should populate the state and the navigationId', () => {
        const { initialState } = fromReducer;
        const action = {
          ...templateAction,
          type: fromNgrxRouter.ROUTER_NAVIGATED,
        };
        const state = fromReducer.reducer(initialState, action);
        expect(state.state).toBe(action.payload.routerState);
      });
      it('should clear nextState', () => {
github SAP / cloud-commerce-spartacus-storefront / projects / core / src / routing / store / reducers / router.reducer.spec.ts View on Github external
it('should clear nextState', () => {
        const initialState: RouterState = {
          ...fromReducer.initialState,
          nextState: {
            url: '',
            queryParams: {},
            params: {},
            context: {
              id: '',
            },
            cmsRequired: false,
          },
        };
        const action = {
          ...templateAction,
          type: fromNgrxRouter.ROUTER_NAVIGATED,
        };
        const state = fromReducer.reducer(initialState, 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
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;
    }
  }
}