-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stark-core): update session actions style
BREAKING CHANGE: Due to an improvement on how actions are defined, the enum `StarkSessionActionsTypes` became obsolete so it has been removed. As a result, the following actions have been changed: - `StarkChangeLanguage(public languageId: string)` -> `StarkSessionActions.changeLanguage({ languageId: string })` - `StarkChangeLanguageSuccess(public languageId: string)` -> `StarkSessionActions.changeLanguageSuccess({ languageId: string })` - `StarkChangeLanguageFailure(public error: any)` -> `StarkSessionActions.changeLanguageFailure({ error: any })` - `StarkInitializeSession(public user: StarkUser)` -> `StarkSessionActions.initializeSession({ user: StarkUser })` - `StarkInitializeSessionSuccess()` -> `StarkSessionActions.initializeSessionSuccess()` - `StarkDestroySession()` -> `StarkSessionActions.destroySession()` - `StarkDestroySessionSuccess()` -> `StarkSessionActions.destroySessionSuccess()` - `StarkSessionTimeoutCountdownStart(public countdown: number)` -> `StarkSessionActions.sessionTimeoutCountdownStart({ countdown: number })` - `StarkSessionTimeoutCountdownStop()` -> `StarkSessionActions.sessionTimeoutCountdownStop()` - `StarkSessionTimeoutCountdownFinish()` -> `StarkSessionActions.sessionTimeoutCountdownFinish()` - `StarkSessionLogout()` -> `StarkSessionActions.sessionLogout()` - `StarkUserActivityTrackingPause()` -> `StarkSessionActions.userActivityTrackingPause()` - `StarkUserActivityTrackingResume()` -> `StarkSessionActions.userActivityTrackingResume()` And also the previous union type has been replaced: `StarkSessionActions` -> `StarkSessionActions.Types`. Change in effect: ```typescript // Before @effect({ dispatch: false }) public starkChangeLanguageSuccess$(): Observable<void> { return this.actions$.pipe( ofType<StarkChangeLanguageSuccess>(StarkSessionActionsTypes.CHANGE_LANGUAGE_SUCCESS), map((action: StarkChangeLanguageSuccess) => { // some logic }) ); } // After public starkChangeLanguageSuccess$ = createEffect( () => this.actions$.pipe( ofType(StarkSessionActions.changeLanguageSuccess), map((action) => { // some logic }) ), { dispatch: false } ); ``` Change in `action` usage: ```typescript // Before this.store.dispatch(new StarkChangeLanguageSuccess(languageId)); // After this.store.dispatch(StarkSessionActions.changeLanguageSuccess({ languageId: languageId })); ```
- Loading branch information
1 parent
727c244
commit 810bbc1
Showing
17 changed files
with
232 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./actions/session.actions"; | ||
import * as StarkSessionActions from "./actions/session.actions"; | ||
export { StarkSessionActions }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,2 @@ | ||
/** | ||
* Name of the initialization states of the application | ||
*/ | ||
export const starkAppInitStateName = "starkAppInit"; | ||
/** | ||
* Name of the exit states of the application | ||
*/ | ||
export const starkAppExitStateName = "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 = "/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 = "/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 = "/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 = "/starkSessionLogout"; | ||
export * from "./constants/session-states"; | ||
export * from "./constants/session-store-key"; |
44 changes: 44 additions & 0 deletions
44
packages/stark-core/src/modules/session/constants/session-states.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "starkAppInit"; | ||
/** | ||
* Name of the exit states of the application | ||
*/ | ||
export const starkAppExitStateName = "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 = "/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 = "/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 = "/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 = "/starkSessionLogout"; |
4 changes: 4 additions & 0 deletions
4
packages/stark-core/src/modules/session/constants/session-store-key.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* Key defined to find the service in a store | ||
*/ | ||
export const starkSessionStoreKey = "StarkSession"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from "./reducers/index"; | ||
export * from "./reducers/session.reducer"; | ||
export { selectStarkSession, starkSessionReducers, StarkSessionState } from "./reducers/index"; | ||
export { sessionReducer } from "./reducers/session.reducer"; |
Oops, something went wrong.