-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
936b7f5
commit 202ffb4
Showing
5 changed files
with
85 additions
and
109 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,39 +1,29 @@ | ||
import { Book } from "src/app/shared/models/book.model"; | ||
import { Action } from "@ngrx/store"; | ||
|
||
export enum BooksApiActionTypes { | ||
BooksLoaded = "[Books API] Books Loaded Success", | ||
BookCreated = "[Books API] Book Created", | ||
BookUpdated = "[Books API] Book Updated", | ||
BookDeleted = "[Books API] Book Deleted" | ||
} | ||
|
||
export class BooksLoaded implements Action { | ||
readonly type = BooksApiActionTypes.BooksLoaded; | ||
|
||
constructor(public books: Book[]) {} | ||
} | ||
|
||
export class BookCreated implements Action { | ||
readonly type = BooksApiActionTypes.BookCreated; | ||
|
||
constructor(public book: Book) {} | ||
} | ||
|
||
export class BookUpdated implements Action { | ||
readonly type = BooksApiActionTypes.BookUpdated; | ||
|
||
constructor(public book: Book) {} | ||
} | ||
|
||
export class BookDeleted implements Action { | ||
readonly type = BooksApiActionTypes.BookDeleted; | ||
|
||
constructor(public book: Book) {} | ||
} | ||
|
||
export type BooksApiActions = | ||
| BooksLoaded | ||
| BookCreated | ||
| BookUpdated | ||
| BookDeleted; | ||
import { createAction, props } from "@ngrx/store"; | ||
|
||
export const booksLoaded = createAction( | ||
"[Books API] Books Loaded Success", | ||
props<{ books: Book[] }>() | ||
); | ||
|
||
export const bookCreated = createAction( | ||
"[Books API] Book Created", | ||
props<{ book: Book }>() | ||
); | ||
|
||
export const bookUpdated = createAction( | ||
"[Books API] Book Updated", | ||
props<{ book: Book }>() | ||
); | ||
|
||
export const bookDeleted = createAction( | ||
"[Books API] Book Deleted", | ||
props<{ book: Book }>() | ||
); | ||
|
||
export type BooksApiActions = ReturnType< | ||
| typeof booksLoaded | ||
| typeof bookCreated | ||
| typeof bookUpdated | ||
| typeof bookDeleted | ||
>; |
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,51 +1,37 @@ | ||
import { Book } from "src/app/shared/models/book.model"; | ||
import { Action } from "@ngrx/store"; | ||
|
||
export enum BooksActionTypes { | ||
Enter = "[Books Page] Enter", | ||
SelectBook = "[Books Page] Select Book", | ||
ClearSelectedBook = "[Books Page] Clear Selected Book", | ||
CreateBook = "[Books Page] Create Book", | ||
UpdateBook = "[Books Page] Update Book", | ||
DeleteBook = "[Books Page] Delete Book" | ||
} | ||
|
||
export class Enter implements Action { | ||
readonly type = BooksActionTypes.Enter; | ||
} | ||
|
||
export class SelectBook implements Action { | ||
readonly type = BooksActionTypes.SelectBook; | ||
|
||
constructor(public bookId: string) {} | ||
} | ||
|
||
export class ClearSelectedBook implements Action { | ||
readonly type = BooksActionTypes.ClearSelectedBook; | ||
} | ||
|
||
export class CreateBook implements Action { | ||
readonly type = BooksActionTypes.CreateBook; | ||
|
||
constructor(public book: Book) {} | ||
} | ||
|
||
export class UpdateBook implements Action { | ||
readonly type = BooksActionTypes.UpdateBook; | ||
|
||
constructor(public book: Book) {} | ||
} | ||
|
||
export class DeleteBook implements Action { | ||
readonly type = BooksActionTypes.DeleteBook; | ||
|
||
constructor(public book: Book) {} | ||
} | ||
|
||
export type BooksActions = | ||
| Enter | ||
| SelectBook | ||
| ClearSelectedBook | ||
| CreateBook | ||
| UpdateBook | ||
| DeleteBook; | ||
import { createAction, props } from "@ngrx/store"; | ||
import { BookRequiredProps, Book } from "src/app/shared/models/book.model"; | ||
|
||
export const enter = createAction("[Books Page] Enter"); | ||
|
||
export const selectBook = createAction( | ||
"[Books Page] Select Book", | ||
props<{ bookId: string }>() | ||
); | ||
|
||
export const clearSelectedBook = createAction( | ||
"[Books Page] Clear Selected Book" | ||
); | ||
|
||
export const createBook = createAction( | ||
"[Books Page] Create Book", | ||
props<{ book: BookRequiredProps }>() | ||
); | ||
|
||
export const updateBook = createAction( | ||
"[Books Page] Update Book", | ||
props<{ book: Book; changes: BookRequiredProps }>() | ||
); | ||
|
||
export const deleteBook = createAction( | ||
"[Books Page] Delete Book", | ||
props<{ book: Book }>() | ||
); | ||
|
||
export type BooksActions = ReturnType< | ||
| typeof enter | ||
| typeof selectBook | ||
| typeof clearSelectedBook | ||
| typeof createBook | ||
| typeof updateBook | ||
| typeof deleteBook | ||
>; |
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