Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(example): update ofType in effects per #1676 #1691

Merged
merged 1 commit into from
Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions projects/example-app/src/app/auth/effects/auth.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { LogoutConfirmationDialogComponent } from '@example-app/auth/components/
export class AuthEffects {
login$ = createEffect(() =>
this.actions$.pipe(
ofType(LoginPageActions.login.type),
ofType(LoginPageActions.login),
map(action => action.credentials),
exhaustMap((auth: Credentials) =>
this.authService.login(auth).pipe(
Expand All @@ -31,7 +31,7 @@ export class AuthEffects {
loginSuccess$ = createEffect(
() =>
this.actions$.pipe(
ofType(AuthApiActions.loginSuccess.type),
ofType(AuthApiActions.loginSuccess),
tap(() => this.router.navigate(['/']))
),
{ dispatch: false }
Expand All @@ -40,7 +40,7 @@ export class AuthEffects {
loginRedirect$ = createEffect(
() =>
this.actions$.pipe(
ofType(AuthApiActions.loginRedirect.type, AuthActions.logout.type),
ofType(AuthApiActions.loginRedirect, AuthActions.logout),
tap(authed => {
this.router.navigate(['/login']);
})
Expand All @@ -50,7 +50,7 @@ export class AuthEffects {

logoutConfirmation$ = createEffect(() =>
this.actions$.pipe(
ofType(AuthActions.logoutConfirmation.type),
ofType(AuthActions.logoutConfirmation),
exhaustMap(() => {
const dialogRef = this.dialog.open<
LogoutConfirmationDialogComponent,
Expand All @@ -70,7 +70,7 @@ export class AuthEffects {
);

constructor(
private actions$: Actions<LoginPageActions.LoginPageActionsUnion>,
private actions$: Actions,
private authService: AuthService,
private router: Router,
private dialog: MatDialog
Expand Down
6 changes: 3 additions & 3 deletions projects/example-app/src/app/books/effects/book.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export class BookEffects {
search$ = createEffect(
() => ({ debounce = 300, scheduler = asyncScheduler } = {}) =>
this.actions$.pipe(
ofType(FindBookPageActions.searchBooks.type),
ofType(FindBookPageActions.searchBooks),
debounceTime(debounce, scheduler),
switchMap(({ query }) => {
if (query === '') {
return empty;
}

const nextSearch$ = this.actions$.pipe(
ofType(FindBookPageActions.searchBooks.type),
ofType(FindBookPageActions.searchBooks),
skip(1)
);

Expand All @@ -57,7 +57,7 @@ export class BookEffects {
);

constructor(
private actions$: Actions<FindBookPageActions.FindBookPageActionsUnion>,
private actions$: Actions,
private googleBooks: GoogleBooksService
) {}
}
10 changes: 4 additions & 6 deletions projects/example-app/src/app/books/effects/collection.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class CollectionEffects {

loadCollection$ = createEffect(() =>
this.actions$.pipe(
ofType(CollectionPageActions.loadCollection.type),
ofType(CollectionPageActions.loadCollection),
switchMap(() =>
this.storageService.getCollection().pipe(
map((books: Book[]) =>
Expand All @@ -42,7 +42,7 @@ export class CollectionEffects {

addBookToCollection$ = createEffect(() =>
this.actions$.pipe(
ofType(SelectedBookPageActions.addBook.type),
ofType(SelectedBookPageActions.addBook),
mergeMap(({ book }) =>
this.storageService.addToCollection([book]).pipe(
map(() => CollectionApiActions.addBookSuccess({ book })),
Expand All @@ -54,7 +54,7 @@ export class CollectionEffects {

removeBookFromCollection$ = createEffect(() =>
this.actions$.pipe(
ofType(SelectedBookPageActions.removeBook.type),
ofType(SelectedBookPageActions.removeBook),
mergeMap(({ book }) =>
this.storageService.removeFromCollection([book.id]).pipe(
map(() => CollectionApiActions.removeBookSuccess({ book })),
Expand All @@ -65,9 +65,7 @@ export class CollectionEffects {
);

constructor(
private actions$: Actions<
SelectedBookPageActions.SelectedBookPageActionsUnion
>,
private actions$: Actions,
private storageService: BookStorageService
) {}
}