NetanelBasal
4/22/2017 - 7:46 PM

et3.ts

@Injectable()
export class PostsEffects {
  constructor( private postsService : PostsService,
               private actions$ : Actions ) {
  }

  @Effect() posts$ = this.actions$
    .ofType(GET_POSTS)
    .switchMap(_ => this.postsService.get()
      .map(posts => getPostsSuccess(posts))
      .catch(error => Observable.of(getPostsFail(error)))
    );
}