Skip to content

Commit

Permalink
refactor(router-store): Rename base router store state interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Aug 22, 2018
1 parent 58c8073 commit 329b0b8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion modules/router-store/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ export {
RouterStateSerializer,
DefaultRouterStateSerializer,
SerializedRouterStateSnapshot,
SimpleRouterState,
BaseRouterStoreState,
} from './serializer';
20 changes: 10 additions & 10 deletions modules/router-store/src/router_store_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
DefaultRouterStateSerializer,
RouterStateSerializer,
SerializedRouterStateSnapshot,
SimpleRouterState,
BaseRouterStoreState,
} from './serializer';

/**
Expand Down Expand Up @@ -49,7 +49,7 @@ export const ROUTER_NAVIGATION = 'ROUTER_NAVIGATION';
/**
* Payload of ROUTER_NAVIGATION.
*/
export type RouterNavigationPayload<T extends SimpleRouterState> = {
export type RouterNavigationPayload<T extends BaseRouterStoreState> = {
routerState: T;
event: RoutesRecognized;
};
Expand All @@ -58,7 +58,7 @@ export type RouterNavigationPayload<T extends SimpleRouterState> = {
* An action dispatched when the router navigates.
*/
export type RouterNavigationAction<
T extends SimpleRouterState = SerializedRouterStateSnapshot
T extends BaseRouterStoreState = SerializedRouterStateSnapshot
> = {
type: typeof ROUTER_NAVIGATION;
payload: RouterNavigationPayload<T>;
Expand All @@ -72,7 +72,7 @@ export const ROUTER_CANCEL = 'ROUTER_CANCEL';
/**
* Payload of ROUTER_CANCEL.
*/
export type RouterCancelPayload<T, V extends SimpleRouterState> = {
export type RouterCancelPayload<T, V extends BaseRouterStoreState> = {
routerState: V;
storeState: T;
event: NavigationCancel;
Expand All @@ -83,7 +83,7 @@ export type RouterCancelPayload<T, V extends SimpleRouterState> = {
*/
export type RouterCancelAction<
T,
V extends SimpleRouterState = SerializedRouterStateSnapshot
V extends BaseRouterStoreState = SerializedRouterStateSnapshot
> = {
type: typeof ROUTER_CANCEL;
payload: RouterCancelPayload<T, V>;
Expand All @@ -97,7 +97,7 @@ export const ROUTER_ERROR = 'ROUTE_ERROR';
/**
* Payload of ROUTER_ERROR.
*/
export type RouterErrorPayload<T, V extends SimpleRouterState> = {
export type RouterErrorPayload<T, V extends BaseRouterStoreState> = {
routerState: V;
storeState: T;
event: NavigationError;
Expand All @@ -108,7 +108,7 @@ export type RouterErrorPayload<T, V extends SimpleRouterState> = {
*/
export type RouterErrorAction<
T,
V extends SimpleRouterState = SerializedRouterStateSnapshot
V extends BaseRouterStoreState = SerializedRouterStateSnapshot
> = {
type: typeof ROUTER_ERROR;
payload: RouterErrorPayload<T, V>;
Expand Down Expand Up @@ -139,7 +139,7 @@ export type RouterNavigatedAction = {
*/
export type RouterAction<
T,
V extends SimpleRouterState = SerializedRouterStateSnapshot
V extends BaseRouterStoreState = SerializedRouterStateSnapshot
> =
| RouterRequestAction
| RouterNavigationAction<V>
Expand All @@ -148,14 +148,14 @@ export type RouterAction<
| RouterNavigatedAction;

export type RouterReducerState<
T extends SimpleRouterState = SerializedRouterStateSnapshot
T extends BaseRouterStoreState = SerializedRouterStateSnapshot
> = {
state: T;
navigationId: number;
};

export function routerReducer<
T extends SimpleRouterState = SerializedRouterStateSnapshot
T extends BaseRouterStoreState = SerializedRouterStateSnapshot
>(
state: RouterReducerState<T> | undefined,
action: RouterAction<any, T>
Expand Down
9 changes: 5 additions & 4 deletions modules/router-store/src/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';

/**
* Simple router state.
* All custom router states / state serializers should have at least this property.
* All custom router states / state serializers should have at least
* the properties of this interface.
*/
export interface SimpleRouterState {
export interface BaseRouterStoreState {
url: string;
}

export abstract class RouterStateSerializer<
T extends SimpleRouterState = SimpleRouterState
T extends BaseRouterStoreState = BaseRouterStoreState
> {
abstract serialize(routerState: RouterStateSnapshot): T;
}

export interface SerializedRouterStateSnapshot extends SimpleRouterState {
export interface SerializedRouterStateSnapshot extends BaseRouterStoreState {
root: ActivatedRouteSnapshot;
url: string;
}
Expand Down

0 comments on commit 329b0b8

Please sign in to comment.