Skip to content

Commit

Permalink
fix(Effects): Export EffectsNotification interface
Browse files Browse the repository at this point in the history
Also updated documentation and added to example app
  • Loading branch information
brandonroberts committed Aug 3, 2017
1 parent f969676 commit 80a48ae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/effects/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -119,7 +119,7 @@ export class UserEffects implements OnRunEffects {
console.log(action);
});

ngrxOnRunEffects(resolvedEffects$: Observable<Action>) {
ngrxOnRunEffects(resolvedEffects$: Observable<EffectsNotification>) {
return this.actions$.ofType('LOGGED_IN')
.exhaustMap(() => resolvedEffects$.takeUntil('LOGGED_OUT'));
}
Expand Down
8 changes: 5 additions & 3 deletions example-app/app/books/effects/collection.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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) {}
Expand Down
1 change: 1 addition & 0 deletions modules/effects/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 80a48ae

Please sign in to comment.