@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)))
);
}