Skip to content

Instantly share code, notes, and snippets.

@jtcrowson
Last active Mar 8, 2019
Embed
What would you like to do?
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