Skip to content

Commit

Permalink
feat(example): update ofType in effects per #1676 (#1691)
Browse files Browse the repository at this point in the history
Closes #1676
  • Loading branch information
wesleygrimes authored and brandonroberts committed Apr 4, 2019
1 parent 45a5781 commit c9c9a0e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
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
) {}
}

0 comments on commit c9c9a0e

Please sign in to comment.