Skip to content

Commit

Permalink
fix(stark-core): avoid circular dependencies by moving state names in…
Browse files Browse the repository at this point in the history
… a constants file
  • Loading branch information
ageorges-nbb committed Jan 7, 2019
1 parent 8ee3938 commit abe7fe2
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { StarkRoutingTransitionHook } from "./routing-transition-hook.constants"
import { StarkStateConfigWithParams } from "./state-config-with-params.intf";
import { StarkCoreApplicationState } from "../../../common/store";
import { StarkConfigurationUtil } from "../../../util/configuration.util";
import { starkAppExitStateName, starkAppInitStateName } from "../../session/routes";
import { starkAppExitStateName, starkAppInitStateName } from "../../session/constants";

/**
* @ignore
Expand Down
1 change: 1 addition & 0 deletions packages/stark-core/src/modules/session.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "./session/actions";
export * from "./session/components";
export * from "./session/constants";
export * from "./session/entities";
export * from "./session/reducers";
export * from "./session/services";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Inject, OnInit, ViewEncapsulation } from "@angular/core";
import { STARK_LOGGING_SERVICE, StarkLoggingService } from "../../logging/services";
import { STARK_ROUTING_SERVICE, StarkRoutingService } from "../../routing/services";
import { starkAppExitStateName, starkAppInitStateName } from "../routes";
import { starkAppExitStateName, starkAppInitStateName } from "../constants";

/**
* Name of the component
Expand Down
44 changes: 44 additions & 0 deletions packages/stark-core/src/modules/session/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Name of the initialization states of the application
*/
export const starkAppInitStateName: string = "starkAppInit";
/**
* Name of the exit states of the application
*/
export const starkAppExitStateName: string = "starkAppExit";

/**
* Name of the login state of the application
*/
export const starkLoginStateName: string = starkAppInitStateName + ".starkLogin";
/**
* URL of the login state of the application
*/
export const starkLoginStateUrl: string = "/starkLogin";

/**
* Name of the Preloading state of the application
*/
export const starkPreloadingStateName: string = starkAppInitStateName + ".starkPreloading";
/**
* URL of the Preloading state of the application
*/
export const starkPreloadingStateUrl: string = "/starkPreloading";

/**
* Name of the SessionExpired state of the application
*/
export const starkSessionExpiredStateName: string = starkAppExitStateName + ".starkSessionExpired";
/**
* URL of the SessionExpired state of the application
*/
export const starkSessionExpiredStateUrl: string = "/starkSessionExpired";

/**
* Name of the SessionLogout state of the application
*/
export const starkSessionLogoutStateName: string = starkAppExitStateName + ".starkSessionLogout";
/**
* URL of the SessionLogout state of the application
*/
export const starkSessionLogoutStateUrl: string = "/starkSessionLogout";
46 changes: 1 addition & 45 deletions packages/stark-core/src/modules/session/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,7 @@ import { loadNgModule, Ng2StateDeclaration, NgModuleToLoad } from "@uirouter/ang
import { from, Observable, of } from "rxjs";
import { map } from "rxjs/operators";
import { STARK_ROUTING_SERVICE, StarkRoutingService, StarkStateConfigWithParams } from "../routing/services";

/**
* Name of the initialization states of the application
*/
export const starkAppInitStateName: string = "starkAppInit";
/**
* Name of the exit states of the application
*/
export const starkAppExitStateName: string = "starkAppExit";

/**
* Name of the login state of the application
*/
export const starkLoginStateName: string = starkAppInitStateName + ".starkLogin";
/**
* URL of the login state of the application
*/
export const starkLoginStateUrl: string = "/starkLogin";

/**
* Name of the Preloading state of the application
*/
export const starkPreloadingStateName: string = starkAppInitStateName + ".starkPreloading";
/**
* URL of the Preloading state of the application
*/
export const starkPreloadingStateUrl: string = "/starkPreloading";

/**
* Name of the SessionExpired state of the application
*/
export const starkSessionExpiredStateName: string = starkAppExitStateName + ".starkSessionExpired";
/**
* URL of the SessionExpired state of the application
*/
export const starkSessionExpiredStateUrl: string = "/starkSessionExpired";

/**
* Name of the SessionLogout state of the application
*/
export const starkSessionLogoutStateName: string = starkAppExitStateName + ".starkSessionLogout";
/**
* URL of the SessionLogout state of the application
*/
export const starkSessionLogoutStateUrl: string = "/starkSessionLogout";
import { starkAppExitStateName, starkAppInitStateName } from "./constants";

/**
* Configuration of the route state of the application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { MockStarkRoutingService } from "../../routing/testing";
import { StarkCoreApplicationState } from "../../../common/store";
import Spy = jasmine.Spy;
import SpyObj = jasmine.SpyObj;
import { starkAppExitStateName, starkAppInitStateName, starkSessionExpiredStateName } from "../routes";
import { starkAppExitStateName, starkAppInitStateName, starkSessionExpiredStateName } from "../constants";

describe("Service: StarkSessionService", () => {
let mockStore: SpyObj<Store<StarkCoreApplicationState>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { StarkCoreApplicationState } from "../../../common/store";
import { selectStarkSession } from "../reducers";
import { StarkConfigurationUtil } from "../../../util/configuration.util";
import { StarkValidationErrorsUtil } from "../../../util";
import { starkAppExitStateName, starkAppInitStateName, starkSessionExpiredStateName } from "../routes";
import { starkAppExitStateName, starkAppInitStateName, starkSessionExpiredStateName } from "../constants";

/**
* @ignore
Expand Down
3 changes: 2 additions & 1 deletion packages/stark-core/src/modules/session/session.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { starkSessionReducers } from "./reducers";
import { StarkSessionConfig, STARK_SESSION_CONFIG } from "./entities";
import { STARK_SESSION_SERVICE, StarkSessionServiceImpl } from "./services";
import { STARK_ROUTING_SERVICE, StarkRoutingService } from "../routing/services";
import { SESSION_STATES, starkLoginStateName, starkPreloadingStateName } from "./routes";
import { SESSION_STATES } from "./routes";
import { starkLoginStateName, starkPreloadingStateName } from "./constants";
import { StarkAppContainerComponent } from "./components";

@NgModule({
Expand Down

0 comments on commit abe7fe2

Please sign in to comment.