-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(example-app): use action creators
- Loading branch information
Showing
13 changed files
with
52 additions
and
79 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
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,24 +1,16 @@ | ||
import { Action } from '@ngrx/store'; | ||
import { Action, ActionsUnion, createAction } from '@ngrx/store'; | ||
|
||
export enum AuthActionTypes { | ||
Logout = '[Auth] Logout', | ||
LogoutConfirmation = '[Auth] Logout Confirmation', | ||
LogoutConfirmationDismiss = '[Auth] Logout Confirmation Dismiss', | ||
} | ||
|
||
export class Logout implements Action { | ||
readonly type = AuthActionTypes.Logout; | ||
} | ||
|
||
export class LogoutConfirmation implements Action { | ||
readonly type = AuthActionTypes.LogoutConfirmation; | ||
} | ||
|
||
export class LogoutConfirmationDismiss implements Action { | ||
readonly type = AuthActionTypes.LogoutConfirmationDismiss; | ||
} | ||
export const AuthActions = { | ||
logout: () => createAction(AuthActionTypes.Logout), | ||
logoutConfirmation: () => createAction(AuthActionTypes.LogoutConfirmation), | ||
logoutConfirmationDismiss: () => | ||
createAction(AuthActionTypes.LogoutConfirmationDismiss), | ||
}; | ||
|
||
export type AuthActionsUnion = | ||
| Logout | ||
| LogoutConfirmation | ||
| LogoutConfirmationDismiss; | ||
export type AuthActions = ActionsUnion<typeof AuthActions>; |
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,8 +1,12 @@ | ||
import * as AuthActions from './auth.actions'; | ||
import { | ||
import { AuthActions, AuthActionTypes } from './auth.actions'; | ||
import { AuthApiActions, AuthApiActionTypes } from './auth-api.actions'; | ||
import { LoginPageActions, LoginPageActionTypes } from './login-page.actions'; | ||
|
||
export { | ||
AuthActions, | ||
AuthActionTypes, | ||
AuthApiActions, | ||
AuthApiActionTypes, | ||
} from '@example-app/auth/actions/auth-api.actions'; | ||
import * as LoginPageActions from './login-page.actions'; | ||
|
||
export { AuthActions, AuthApiActions, AuthApiActionTypes, LoginPageActions }; | ||
LoginPageActions, | ||
LoginPageActionTypes, | ||
}; |
13 changes: 6 additions & 7 deletions
13
projects/example-app/src/app/auth/actions/login-page.actions.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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
import { Action } from '@ngrx/store'; | ||
import { ActionsUnion, createAction } from '@ngrx/store'; | ||
import { Credentials } from '@example-app/auth/models/user'; | ||
|
||
export enum LoginPageActionTypes { | ||
Login = '[Login Page] Login', | ||
} | ||
|
||
export class Login implements Action { | ||
readonly type = LoginPageActionTypes.Login; | ||
export const LoginPageActions = { | ||
login: (credentials: Credentials) => | ||
createAction(LoginPageActionTypes.Login, { credentials }), | ||
}; | ||
|
||
constructor(public payload: { credentials: Credentials }) {} | ||
} | ||
|
||
export type LoginPageActionsUnion = Login; | ||
export type LoginPageActions = ActionsUnion<typeof LoginPageActions>; |
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
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
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
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
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