Skip to content

Instantly share code, notes, and snippets.

@jtcrowson
Last active March 8, 2019 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtcrowson/191c435185b2dbd46bd3ca6335ae67e7 to your computer and use it in GitHub Desktop.
Save jtcrowson/191c435185b2dbd46bd3ca6335ae67e7 to your computer and use it in GitHub Desktop.
Adapted book.effects.ts from version 7.3.0 of ngrx/platform
@Injectable()
export class BookEffects {
@Effect({ dispatch: false })
addBookSuccess$ = this.actions$.pipe(
ofType(CollectionApiActionTypes.AddBookSuccess),
withLatestFrom(this.store.select(fromBooks.getCollectionBookIds)),
tap(([action, bookCollection]) => {
if (bookCollection.length === 1) {
window.alert('Congrats on adding your first book!')
} else {
window.alert('You have added book number ' + bookCollection.length);
}
})
);
// search$ effect deleted for simplicity
constructor(
private actions$: Actions<FindBookPageActions.FindBookPageActionsUnion>,
// ...
private store: Store<fromBooks.State>
) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment