Skip to content

Commit

Permalink
refactor(example-app): use action creators
Browse files Browse the repository at this point in the history
  • Loading branch information
tja4472 committed Mar 2, 2019
1 parent 9f9d2a3 commit c8fc6b9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 35 deletions.
22 changes: 1 addition & 21 deletions projects/example-app/src/app/auth/actions/auth-api.actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ActionsUnion, createAction } from '@ngrx/store';
import { User } from '@example-app/auth/models/user';

export const enum AuthApiActionTypes {
export enum AuthApiActionTypes {
LoginSuccess = '[Auth/API] Login Success',
LoginFailure = '[Auth/API] Login Failure',
LoginRedirect = '[Auth/API] Login Redirect',
Expand All @@ -16,23 +16,3 @@ export const AuthApiActions = {
};

export type AuthApiActions = ActionsUnion<typeof AuthApiActions>;

/*
export class LoginSuccess implements Action {
readonly type = AuthApiActionTypes.LoginSuccess;
constructor(public payload: { user: User }) {}
}
export class LoginFailure implements Action {
readonly type = AuthApiActionTypes.LoginFailure;
constructor(public payload: { error: any }) {}
}
export class LoginRedirect implements Action {
readonly type = AuthApiActionTypes.LoginRedirect;
}
export type AuthApiActionsUnion = LoginSuccess | LoginFailure | LoginRedirect;
*/
15 changes: 3 additions & 12 deletions projects/example-app/src/app/auth/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import {
AuthActions,
AuthActionTypes,
} from '@example-app/auth/actions/auth.actions';
import {
AuthApiActions,
AuthApiActionTypes,
} from '@example-app/auth/actions/auth-api.actions';
import {
LoginPageActions,
LoginPageActionTypes,
} from '@example-app/auth/actions/login-page.actions';
import { AuthActions, AuthActionTypes } from './auth.actions';
import { AuthApiActions, AuthApiActionTypes } from './auth-api.actions';
import { LoginPageActions, LoginPageActionTypes } from './login-page.actions';

export {
AuthActions,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ActionsUnion, createAction } from '@ngrx/store';
import { Credentials } from '@example-app/auth/models/user';

export const enum LoginPageActionTypes {
export enum LoginPageActionTypes {
Login = '[Login Page] Login',
}

Expand Down
1 change: 0 additions & 1 deletion projects/example-app/src/app/auth/effects/auth.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class AuthEffects {
map(action => action.credentials),
exhaustMap((auth: Credentials) =>
this.authService.login(auth).pipe(
// map(user => AuthApiActions.AuthApiActions.loginSuccess(user)),
map(AuthApiActions.loginSuccess),
catchError(error => of(AuthApiActions.loginFailure(error)))
)
Expand Down

0 comments on commit c8fc6b9

Please sign in to comment.