Skip to content

Instantly share code, notes, and snippets.

@jplemieux66
Last active June 17, 2018 18:54
Show Gist options
  • Save jplemieux66/11d1c84d058926660588821f664dba67 to your computer and use it in GitHub Desktop.
Save jplemieux66/11d1c84d058926660588821f664dba67 to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { Actions, Effect } from '@ngrx/effects';
import { Action } from '@ngrx/store';
import { Observable, of } from 'rxjs';
import * as project from './../actions/projects';
import { ProjectsService } from './../services/projects.service';
@Injectable()
export class ProjectEffects {
@Effect()
loadProjectsDetails$: Observable<Action> = this.actions$
.ofType<project.LoadProjectsDetails>(project.LOAD_PROJECTS_DETAILS)
.switchMap(action =>
this.projectsService.loadProjectsDetails(action.payload)
.map(projectDetails => new project.LoadProjectsDetailsSuccess(projectDetails))
.catch((error) => of(new project.LoadProjectsDetailsError(error)))
);
constructor(private actions$: Actions,
private projectsService: ProjectsService) { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment