From 80a48ae8ef18d2cbe6d7fb2dcdb1d2d810a99562 Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Thu, 3 Aug 2017 08:11:42 -0500 Subject: [PATCH] fix(Effects): Export EffectsNotification interface Also updated documentation and added to example app --- docs/effects/api.md | 4 ++-- example-app/app/books/effects/collection.ts | 8 +++++--- modules/effects/src/index.ts | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/effects/api.md b/docs/effects/api.md index d27d7bd8e2..ffdbf151a0 100644 --- a/docs/effects/api.md +++ b/docs/effects/api.md @@ -107,7 +107,7 @@ import 'rxjs/add/operator/takeUntil'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { Action } from '@ngrx/store'; -import { Actions, Effect, OnRunEffects } from '@ngrx/effects'; +import { Actions, Effect, OnRunEffects, EffectsNotification } from '@ngrx/effects'; @Injectable() export class UserEffects implements OnRunEffects { @@ -119,7 +119,7 @@ export class UserEffects implements OnRunEffects { console.log(action); }); - ngrxOnRunEffects(resolvedEffects$: Observable) { + ngrxOnRunEffects(resolvedEffects$: Observable) { return this.actions$.ofType('LOGGED_IN') .exhaustMap(() => resolvedEffects$.takeUntil('LOGGED_OUT')); } diff --git a/example-app/app/books/effects/collection.ts b/example-app/app/books/effects/collection.ts index d14ecebba3..4c12ebf6c4 100644 --- a/example-app/app/books/effects/collection.ts +++ b/example-app/app/books/effects/collection.ts @@ -1,5 +1,6 @@ import 'rxjs/add/operator/map'; import 'rxjs/add/operator/catch'; +import 'rxjs/add/operator/exhaustMap'; import 'rxjs/add/operator/switchMap'; import 'rxjs/add/operator/mergeMap'; import 'rxjs/add/operator/toArray'; @@ -12,6 +13,7 @@ import { defer } from 'rxjs/observable/defer'; import { of } from 'rxjs/observable/of'; import * as collection from '../actions/collection'; +import * as auth from '../../auth/actions/auth'; import { Book } from '../models/book'; @Injectable() @@ -39,7 +41,7 @@ export class CollectionEffects { .query('books') .toArray() .map((books: Book[]) => new collection.LoadSuccessAction(books)) - .catch(error => of(new collection.LoadFailAction(error))) + .catch(error => of(new collection.LoadFailAction(error))), ); @Effect() @@ -50,7 +52,7 @@ export class CollectionEffects { this.db .insert('books', [book]) .map(() => new collection.AddBookSuccessAction(book)) - .catch(() => of(new collection.AddBookFailAction(book))) + .catch(() => of(new collection.AddBookFailAction(book))), ); @Effect() @@ -61,7 +63,7 @@ export class CollectionEffects { this.db .executeWrite('books', 'delete', [book.id]) .map(() => new collection.RemoveBookSuccessAction(book)) - .catch(() => of(new collection.RemoveBookFailAction(book))) + .catch(() => of(new collection.RemoveBookFailAction(book))), ); constructor(private actions$: Actions, private db: Database) {} diff --git a/modules/effects/src/index.ts b/modules/effects/src/index.ts index c314508b9a..cd112564fb 100644 --- a/modules/effects/src/index.ts +++ b/modules/effects/src/index.ts @@ -5,3 +5,4 @@ export { EffectsModule } from './effects_module'; export { EffectSources } from './effect_sources'; export { OnRunEffects } from './on_run_effects'; export { toPayload } from './util'; +export { EffectNotification } from './effect_notification';