-
-
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 create action group function for actions (#…
- Loading branch information
1 parent
b90da9d
commit 4b310dd
Showing
45 changed files
with
170 additions
and
208 deletions.
There are no files selected for viewing
21 changes: 9 additions & 12 deletions
21
projects/example-app/src/app/auth/actions/auth-api.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,11 @@ | ||
import { props, createAction } from '@ngrx/store'; | ||
import { props, createActionGroup, emptyProps } from '@ngrx/store'; | ||
import { User } from '@example-app/auth/models'; | ||
|
||
export const loginSuccess = createAction( | ||
'[Auth/API] Login Success', | ||
props<{ user: User }>() | ||
); | ||
|
||
export const loginFailure = createAction( | ||
'[Auth/API] Login Failure', | ||
props<{ error: any }>() | ||
); | ||
|
||
export const loginRedirect = createAction('[Auth/API] Login Redirect'); | ||
export const AuthApiActions = createActionGroup({ | ||
source: 'Auth/API', | ||
events: { | ||
'Login Success': props<{ user: User }>(), | ||
'Login Failure': props<{ error: any }>(), | ||
'Login Redirect': emptyProps(), | ||
}, | ||
}); |
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,7 +1,10 @@ | ||
import { createAction } from '@ngrx/store'; | ||
import { createActionGroup, emptyProps } from '@ngrx/store'; | ||
|
||
export const logout = createAction('[Auth] Logout'); | ||
export const logoutConfirmation = createAction('[Auth] Logout Confirmation'); | ||
export const logoutConfirmationDismiss = createAction( | ||
'[Auth] Logout Confirmation Dismiss' | ||
); | ||
export const AuthActions = createActionGroup({ | ||
source: 'Auth', | ||
events: { | ||
Logout: emptyProps(), | ||
'Logout Confirmation': emptyProps(), | ||
'Logout Confirmation Dismiss': emptyProps(), | ||
}, | ||
}); |
This file was deleted.
Oops, something went wrong.
12 changes: 7 additions & 5 deletions
12
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,7 +1,9 @@ | ||
import { createAction, props } from '@ngrx/store'; | ||
import { createActionGroup, props } from '@ngrx/store'; | ||
import { Credentials } from '@example-app/auth/models'; | ||
|
||
export const login = createAction( | ||
'[Login Page] Login', | ||
props<{ credentials: Credentials }>() | ||
); | ||
export const LoginPageActions = createActionGroup({ | ||
source: 'Login Page', | ||
events: { | ||
Login: props<{ credentials: Credentials }>(), | ||
}, | ||
}); |
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
3 changes: 2 additions & 1 deletion
3
projects/example-app/src/app/auth/reducers/auth.reducer.spec.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
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
3 changes: 2 additions & 1 deletion
3
projects/example-app/src/app/auth/reducers/login-page.reducer.spec.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
3 changes: 2 additions & 1 deletion
3
projects/example-app/src/app/auth/reducers/login-page.reducer.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
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,8 +1,10 @@ | ||
import { createAction, props } from '@ngrx/store'; | ||
import { createActionGroup, props } from '@ngrx/store'; | ||
|
||
import { Book } from '@example-app/books/models'; | ||
|
||
export const loadBook = createAction( | ||
'[Book Exists Guard] Load Book', | ||
props<{ book: Book }>() | ||
); | ||
export const BookActions = createActionGroup({ | ||
source: 'Book Exists Guard', | ||
events: { | ||
'Load Book': props<{ book: Book }>(), | ||
}, | ||
}); |
18 changes: 8 additions & 10 deletions
18
projects/example-app/src/app/books/actions/books-api.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,13 +1,11 @@ | ||
import { createAction, props } from '@ngrx/store'; | ||
import { createActionGroup, props } from '@ngrx/store'; | ||
|
||
import { Book } from '@example-app/books/models'; | ||
|
||
export const searchSuccess = createAction( | ||
'[Books/API] Search Success', | ||
props<{ books: Book[] }>() | ||
); | ||
|
||
export const searchFailure = createAction( | ||
'[Books/API] Search Failure', | ||
props<{ errorMsg: string }>() | ||
); | ||
export const BooksApiActions = createActionGroup({ | ||
source: 'Books/API', | ||
events: { | ||
'Search Success': props<{ books: Book[] }>(), | ||
'Search Failure': props<{ errorMsg: string }>(), | ||
}, | ||
}); |
58 changes: 21 additions & 37 deletions
58
projects/example-app/src/app/books/actions/collection-api.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,42 +1,26 @@ | ||
import { createAction, props } from '@ngrx/store'; | ||
import { createActionGroup, props } from '@ngrx/store'; | ||
|
||
import { Book } from '@example-app/books/models'; | ||
|
||
/** | ||
* Add Book to Collection Actions | ||
*/ | ||
export const addBookSuccess = createAction( | ||
'[Collection/API] Add Book Success', | ||
props<{ book: Book }>() | ||
); | ||
export const CollectionApiActions = createActionGroup({ | ||
source: 'Collection/API', | ||
events: { | ||
/** | ||
* Add Book to Collection Actions | ||
*/ | ||
'Add Book Success': props<{ book: Book }>(), | ||
'Add Book Failure': props<{ book: Book }>(), | ||
|
||
export const addBookFailure = createAction( | ||
'[Collection/API] Add Book Failure', | ||
props<{ book: Book }>() | ||
); | ||
/** | ||
* Remove Book from Collection Actions | ||
*/ | ||
'Remove Book Success': props<{ book: Book }>(), | ||
'Remove Book Failure': props<{ book: Book }>(), | ||
|
||
/** | ||
* Remove Book from Collection Actions | ||
*/ | ||
export const removeBookSuccess = createAction( | ||
'[Collection/API] Remove Book Success', | ||
props<{ book: Book }>() | ||
); | ||
|
||
export const removeBookFailure = createAction( | ||
'[Collection/API] Remove Book Failure', | ||
props<{ book: Book }>() | ||
); | ||
|
||
/** | ||
* Load Collection Actions | ||
*/ | ||
export const loadBooksSuccess = createAction( | ||
'[Collection/API] Load Books Success', | ||
props<{ books: Book[] }>() | ||
); | ||
|
||
export const loadBooksFailure = createAction( | ||
'[Collection/API] Load Books Failure', | ||
props<{ error: any }>() | ||
); | ||
/** | ||
* Load Collection Actions | ||
*/ | ||
'Load Books Success': props<{ books: Book[] }>(), | ||
'Load Books Failure': props<{ error: any }>(), | ||
}, | ||
}); |
15 changes: 10 additions & 5 deletions
15
projects/example-app/src/app/books/actions/collection-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,6 +1,11 @@ | ||
import { createAction } from '@ngrx/store'; | ||
import { createActionGroup, emptyProps } from '@ngrx/store'; | ||
|
||
/** | ||
* Load Collection Action | ||
*/ | ||
export const enter = createAction('[Collection Page] Enter'); | ||
export const CollectionPageActions = createActionGroup({ | ||
source: 'Collection Page', | ||
events: { | ||
/** | ||
* Load Collection Action | ||
*/ | ||
Enter: emptyProps(), | ||
}, | ||
}); |
12 changes: 7 additions & 5 deletions
12
projects/example-app/src/app/books/actions/find-book-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,6 +1,8 @@ | ||
import { createAction, props } from '@ngrx/store'; | ||
import { createActionGroup, props } from '@ngrx/store'; | ||
|
||
export const searchBooks = createAction( | ||
'[Find Book Page] Search Books', | ||
props<{ query: string }>() | ||
); | ||
export const FindBookPageActions = createActionGroup({ | ||
source: 'Find Book Page', | ||
events: { | ||
'Search Books': props<{ query: string }>(), | ||
}, | ||
}); |
This file was deleted.
Oops, something went wrong.
29 changes: 14 additions & 15 deletions
29
projects/example-app/src/app/books/actions/selected-book-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,19 +1,18 @@ | ||
import { createAction, props } from '@ngrx/store'; | ||
import { createActionGroup, props } from '@ngrx/store'; | ||
|
||
import { Book } from '@example-app/books/models'; | ||
|
||
/** | ||
* Add Book to Collection Action | ||
*/ | ||
export const addBook = createAction( | ||
'[Selected Book Page] Add Book', | ||
props<{ book: Book }>() | ||
); | ||
export const SelectedBookPageActions = createActionGroup({ | ||
source: 'Selected Book Page', | ||
events: { | ||
/** | ||
* Add Book to Collection Action | ||
*/ | ||
'Add Book': props<{ book: Book }>(), | ||
|
||
/** | ||
* Remove Book from Collection Action | ||
*/ | ||
export const removeBook = createAction( | ||
'[Selected Book Page] Remove Book', | ||
props<{ book: Book }>() | ||
); | ||
/** | ||
* Remove Book from Collection Action | ||
*/ | ||
'Remove Book': props<{ book: Book }>(), | ||
}, | ||
}); |
12 changes: 7 additions & 5 deletions
12
projects/example-app/src/app/books/actions/view-book-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,6 +1,8 @@ | ||
import { createAction, props } from '@ngrx/store'; | ||
import { createActionGroup, props } from '@ngrx/store'; | ||
|
||
export const selectBook = createAction( | ||
'[View Book Page] Select Book', | ||
props<{ id: string }>() | ||
); | ||
export const ViewBookPageActions = createActionGroup({ | ||
source: 'View Book Page', | ||
events: { | ||
'Select Book': props<{ id: string }>(), | ||
}, | ||
}); |
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
Oops, something went wrong.