Last active
June 17, 2018 18:54
-
-
Save jplemieux66/11d1c84d058926660588821f664dba67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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