import {CALL_HISTORY_METHOD, LOCATION_CHANGE, routerReducer, RouterState} from "react-router-redux"; import {IAData, IReduxActionConstructor, ISingleReducer, ReduxAction} from "../action"; import {reducerFromNative} from "../combine-reducers"; import {VirtualStore} from "../virtual-store"; export interface IStateRouter { routing: RouterState; } export class routing extends VirtualStore { // this is a virtual-store constructor() { super(); this.reduceAny({ name: LOCATION_CHANGE, }, reducerFromNative(routerReducer)) } defaultValue: RouterState = { location: null, }; protected reduce(Action: IReduxActionConstructor, ...reducer: ISingleReducer[]): void { this.reduceAny.apply(this, arguments); } } export enum RoutingMethod { push, replace, go, goBack, goForward, } export interface IRoutingData { method: RoutingMethod; url?: string; args?: string[]; } export class RouteAction extends ReduxAction { public readonly type: string; constructor(payload: IRoutingData) { payload.args = [payload.url]; payload.method = RoutingMethod[payload.method]; super(payload); this.type = CALL_HISTORY_METHOD; } }